[−][src]Struct stdweb::web::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 JsSerialize for WebSocket
[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]
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]
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]
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]
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]
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]
impl InstanceOf for WebSocket
[src]
fn instance_of(reference: &Reference) -> bool
[src]
impl ReferenceType for WebSocket
[src]
unsafe fn from_reference_unchecked(reference: Reference) -> Self
[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,
fn dispatch_event<T: IEvent>(&self, event: &T) -> Result<bool, TODO>
[src]
impl AsRef<Reference> for WebSocket
[src]
impl From<WebSocket> for EventTarget
[src]
impl From<WebSocket> for Reference
[src]
impl Clone for WebSocket
[src]
impl Eq for WebSocket
[src]
impl PartialEq<WebSocket> for WebSocket
[src]
impl Debug for WebSocket
[src]
Auto Trait Implementations
impl Send for WebSocket
impl Sync for WebSocket
impl Unpin for WebSocket
impl UnwindSafe for WebSocket
impl RefUnwindSafe for WebSocket
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,