pub struct WebSocketBuilder { /* private fields */ }
Expand description
Builder for connecting a WebSocket.
Implementations§
Source§impl WebSocketBuilder
impl WebSocketBuilder
Sourcepub fn new(url: impl AsRef<str>) -> Self
pub fn new(url: impl AsRef<str>) -> Self
Creates a new WebSocket builder that will connect to the specified URL.
Sourcepub fn set_interface(&mut self, interface: Interface)
pub fn set_interface(&mut self, interface: Interface)
Sets the WebSocket browser interface to use.
If unset, the stream-based interface is preferred when available.
Sourcepub fn set_protocols<P>(&mut self, protocols: impl IntoIterator<Item = P>)
pub fn set_protocols<P>(&mut self, protocols: impl IntoIterator<Item = P>)
Sets the sub-protocol(s) that the client would like to use.
Subprotocols may be selected from the IANA WebSocket Subprotocol Name Registry or may be custom names jointly understood by the client and the server. A single server can implement multiple WebSocket sub-protocols, and handle different types of interactions depending on the specified value.
If protocols is included, the connection will only be established if the server reports that it has selected one of these sub-protocols.
Sourcepub fn set_send_buffer_size(&mut self, send_buffer_size: usize)
pub fn set_send_buffer_size(&mut self, send_buffer_size: usize)
Sets the maximum send buffer size in bytes.
The behavior depends on which WebSocket interface is used:
-
For the standard WebSocket interface: when the maximum send buffer size is reached, all sending function stop accepting data until the send buffer size falls below the specified size.
-
For the stream-baed WebSocket interface: when the maximum send buffer size is reach, the application yields to the browser, which decides whether more data can be buffered or not.
Sourcepub fn set_receive_buffer_size(&mut self, receive_buffer_size: usize)
pub fn set_receive_buffer_size(&mut self, receive_buffer_size: usize)
Sets the maximum receive buffer size in bytes.
This only affects the standard WebSocket interface.
If the maximum receive buffer size is reached, the WebSocket is closed and an error is returned when trying to read from it.
When using the stream-baed WebSocket interface, the receive buffer size is fully managed by the browser.
Trait Implementations§
Source§impl Clone for WebSocketBuilder
impl Clone for WebSocketBuilder
Source§fn clone(&self) -> WebSocketBuilder
fn clone(&self) -> WebSocketBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more