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]
pub fn new(url: &str) -> Result<WebSocket, CreationError>
[src]
Returns a newly constructed WebSocket
.
pub fn new_with_protocols(
url: &str,
protocols: &[&str]
) -> Result<WebSocket, CreationError>
[src]
url: &str,
protocols: &[&str]
) -> Result<WebSocket, CreationError>
Returns a newly constructed WebSocket
.
pub fn binary_type(&self) -> SocketBinaryType
[src]
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]
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]
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]
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]
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]
Returns the current state of the connection.
pub fn url(&self) -> String
[src]
Returns the URL as resolved by the constructor. This is always an absolute URL.
pub fn close(&self)
[src]
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]
&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]
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]
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]
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]
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]
fn clone(&self) -> WebSocket
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for WebSocket
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl PartialEq for WebSocket
[src]
fn eq(&self, __arg_0: &WebSocket) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &WebSocket) -> bool
[src]
This method tests for !=
.
impl Eq for WebSocket
[src]
impl From<WebSocket> for EventTarget
[src]
impl TryFrom<EventTarget> for WebSocket
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: EventTarget) -> Result<Self, Self::Error>
[src]
Performs the conversion.
impl InstanceOf for WebSocket
[src]
fn instance_of(reference: &Reference) -> bool
[src]
Checks whenever a given Reference if of type Self
.
impl AsRef<Reference> for WebSocket
[src]
impl ReferenceType for WebSocket
[src]
unsafe fn from_reference_unchecked(reference: Reference) -> Self
[src]
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 TryFrom<WebSocket> for Reference
[src]
type Error = Void
The type returned in the event of a conversion error.
fn try_from(value: WebSocket) -> Result<Self, Self::Error>
[src]
Performs the conversion.
impl TryFrom<Reference> for WebSocket
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(reference: Reference) -> Result<Self, Self::Error>
[src]
Performs the conversion.
impl<'_r> TryFrom<&'_r Reference> for WebSocket
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(reference: &Reference) -> Result<Self, Self::Error>
[src]
Performs the conversion.
impl TryFrom<Value> for WebSocket
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: Value) -> Result<Self, Self::Error>
[src]
Performs the conversion.
impl<'_r> TryFrom<&'_r Value> for WebSocket
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: &Value) -> Result<Self, Self::Error>
[src]
Performs the conversion.
impl JsSerialize for WebSocket
[src]
impl IEventTarget for WebSocket
[src]
fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandle where
T: ConcreteEvent,
F: FnMut(T) + 'static,
[src]
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]
Dispatches an Event
at this EventTarget
, invoking the affected event listeners in the appropriate order. Read more