Struct stdweb::web::WebSocket [−][src]
pub struct WebSocket(_);
The WebSocket object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
Methods
impl WebSocket
[src]
impl WebSocket
pub fn new(url: &str) -> Result<WebSocket, CreationError>
[src]
pub fn new(url: &str) -> Result<WebSocket, CreationError>
Returns a newly constructed WebSocket
.
pub fn new_with_protocols(
url: &str,
protocols: &[&str]
) -> Result<WebSocket, CreationError>
[src]
pub fn new_with_protocols(
url: &str,
protocols: &[&str]
) -> Result<WebSocket, CreationError>
Returns a newly constructed WebSocket
.
pub fn binary_type(&self) -> SocketBinaryType
[src]
pub fn binary_type(&self) -> SocketBinaryType
Returns the binary type of the web socket. Only affects received messages.
The default binary type is Blob
.
pub fn set_binary_type(&self, binary_type: SocketBinaryType)
[src]
pub fn set_binary_type(&self, binary_type: SocketBinaryType)
Sets the binary type of the web socket. Only affects received messages.
The default binary type is Blob
.
pub fn buffered_amount(&self) -> u64
[src]
pub fn buffered_amount(&self) -> u64
Returns the number of bytes of data that have been queued using calls to send() but not yet transmitted to the network. This value resets to zero once all queued data has been sent. This value does not reset to zero when the connection is closed; if you keep calling send(), this will continue to climb.
pub fn extensions(&self) -> String
[src]
pub fn extensions(&self) -> String
Returns the extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection.
pub fn protocol(&self) -> String
[src]
pub fn protocol(&self) -> String
Returns a string indicating the name of the sub-protocol the server selected; this will be one of the strings specified in the protocols parameter when creating the WebSocket object.
pub fn ready_state(&self) -> SocketReadyState
[src]
pub fn ready_state(&self) -> SocketReadyState
Returns the current state of the connection.
pub fn url(&self) -> String
[src]
pub fn url(&self) -> String
Returns the URL as resolved by the constructor. This is always an absolute URL.
pub fn close(&self)
[src]
pub fn close(&self)
Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.
pub fn close_with_status(
&self,
code: SocketCloseCode,
reason: &str
) -> Result<(), CloseError>
[src]
pub fn close_with_status(
&self,
code: SocketCloseCode,
reason: &str
) -> Result<(), CloseError>
Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.
pub fn send_text(&self, text: &str) -> Result<(), TODO>
[src]
pub fn send_text(&self, text: &str) -> Result<(), TODO>
Enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data. If the data can't be sent (for example, because it needs to be buffered but the buffer is full), the socket is closed automatically.
pub fn send_blob(&self, blob: &Blob) -> Result<(), TODO>
[src]
pub fn send_blob(&self, blob: &Blob) -> Result<(), TODO>
Enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data. If the data can't be sent (for example, because it needs to be buffered but the buffer is full), the socket is closed automatically.
pub fn send_array_buffer(&self, array_buffer: &ArrayBuffer) -> Result<(), TODO>
[src]
pub fn send_array_buffer(&self, array_buffer: &ArrayBuffer) -> Result<(), TODO>
Enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data. If the data can't be sent (for example, because it needs to be buffered but the buffer is full), the socket is closed automatically.
pub fn send_bytes(&self, bytes: &[u8]) -> Result<(), TODO>
[src]
pub fn send_bytes(&self, bytes: &[u8]) -> Result<(), TODO>
Enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data. If the data can't be sent (for example, because it needs to be buffered but the buffer is full), the socket is closed automatically.
Trait Implementations
impl Clone for WebSocket
[src]
impl Clone for WebSocket
fn clone(&self) -> WebSocket
[src]
fn clone(&self) -> WebSocket
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for WebSocket
[src]
impl Debug for WebSocket
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for WebSocket
[src]
impl PartialEq for WebSocket
fn eq(&self, other: &WebSocket) -> bool
[src]
fn eq(&self, other: &WebSocket) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &WebSocket) -> bool
[src]
fn ne(&self, other: &WebSocket) -> bool
This method tests for !=
.
impl Eq for WebSocket
[src]
impl Eq for WebSocket
impl From<WebSocket> for EventTarget
[src]
impl From<WebSocket> for EventTarget
impl TryFrom<EventTarget> for WebSocket
[src]
impl TryFrom<EventTarget> for WebSocket
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: EventTarget) -> Result<Self, Self::Error>
[src]
fn try_from(value: EventTarget) -> Result<Self, Self::Error>
Performs the conversion.
impl InstanceOf for WebSocket
[src]
impl InstanceOf for WebSocket
fn instance_of(reference: &Reference) -> bool
[src]
fn instance_of(reference: &Reference) -> bool
Checks whenever a given Reference if of type Self
.
impl AsRef<Reference> for WebSocket
[src]
impl AsRef<Reference> for WebSocket
impl ReferenceType for WebSocket
[src]
impl ReferenceType for WebSocket
unsafe fn from_reference_unchecked(reference: Reference) -> Self
[src]
unsafe fn from_reference_unchecked(reference: Reference) -> Self
Converts a given reference into a concrete reference-like wrapper. Doesn't do any type checking; highly unsafe to use! Read more
impl From<WebSocket> for Reference
[src]
impl From<WebSocket> for Reference
impl TryFrom<WebSocket> for Reference
[src]
impl TryFrom<WebSocket> for Reference
type Error = Void
The type returned in the event of a conversion error.
fn try_from(value: WebSocket) -> Result<Self, Self::Error>
[src]
fn try_from(value: WebSocket) -> Result<Self, Self::Error>
Performs the conversion.
impl TryFrom<Reference> for WebSocket
[src]
impl TryFrom<Reference> for WebSocket
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(reference: Reference) -> Result<Self, Self::Error>
[src]
fn try_from(reference: Reference) -> Result<Self, Self::Error>
Performs the conversion.
impl<'_r> TryFrom<&'_r Reference> for WebSocket
[src]
impl<'_r> TryFrom<&'_r Reference> for WebSocket
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(reference: &Reference) -> Result<Self, Self::Error>
[src]
fn try_from(reference: &Reference) -> Result<Self, Self::Error>
Performs the conversion.
impl TryFrom<Value> for WebSocket
[src]
impl TryFrom<Value> for WebSocket
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: Value) -> Result<Self, Self::Error>
[src]
fn try_from(value: Value) -> Result<Self, Self::Error>
Performs the conversion.
impl<'_r> TryFrom<&'_r Value> for WebSocket
[src]
impl<'_r> TryFrom<&'_r Value> for WebSocket
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: &Value) -> Result<Self, Self::Error>
[src]
fn try_from(value: &Value) -> Result<Self, Self::Error>
Performs the conversion.
impl JsSerialize for WebSocket
[src]
impl JsSerialize for WebSocket
impl IEventTarget for WebSocket
[src]
impl IEventTarget for WebSocket
fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandle where
T: ConcreteEvent,
F: FnMut(T) + 'static,
[src]
fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandle where
T: ConcreteEvent,
F: FnMut(T) + 'static,
Adds given event handler to the list of event listeners for the specified EventTarget
on which it's called. Read more
fn dispatch_event<T: IEvent>(&self, event: &T) -> Result<bool, TODO>
[src]
fn dispatch_event<T: IEvent>(&self, event: &T) -> Result<bool, TODO>
Dispatches an Event
at this EventTarget
, invoking the affected event listeners in the appropriate order. Read more