Struct parity_ws::WebSocket [−][src]
The WebSocket struct. A WebSocket can support multiple incoming and outgoing connections.
Implementations
impl<F> WebSocket<F> where
F: Factory,
[src]
F: Factory,
pub fn new(factory: F) -> Result<WebSocket<F>>
[src]
Create a new WebSocket using the given Factory to create handlers.
pub fn bind<A>(self, addr_spec: A) -> Result<WebSocket<F>> where
A: ToSocketAddrs,
[src]
A: ToSocketAddrs,
Consume the WebSocket and bind to the specified address.
If the addr_spec
yields multiple addresses this will return after the
first successful bind. local_addr
can be called to determine which
address it ended up binding to.
After the server is successfully bound you should start it using run
.
pub fn listen<A>(self, addr_spec: A) -> Result<WebSocket<F>> where
A: ToSocketAddrs,
[src]
A: ToSocketAddrs,
Consume the WebSocket and listen for new connections on the specified address.
Safety
This method will block until the event loop finishes running.
pub fn connect(&mut self, url: Url) -> Result<&mut WebSocket<F>>
[src]
Queue an outgoing connection on this WebSocket. This method may be called multiple times,
but the actual connections will not be established until run
is called.
pub fn run(self) -> Result<WebSocket<F>>
[src]
Run the WebSocket. This will run the encapsulated event loop blocking the calling thread until the WebSocket is shutdown.
pub fn broadcaster(&self) -> Sender
[src]
Get a Sender that can be used to send messages on all connections.
Calling send
on this Sender is equivalent to calling broadcast
.
Calling shutdown
on this Sender will shutdown the WebSocket even if no connections have
been established.
pub fn local_addr(&self) -> Result<SocketAddr>
[src]
Get the local socket address this socket is bound to. Will return an error
if the backend returns an error. Will return a NotFound
error if
this WebSocket is not a listening socket.
Auto Trait Implementations
impl<F> !RefUnwindSafe for WebSocket<F>
impl<F> Send for WebSocket<F> where
F: Send,
<F as Factory>::Handler: Send,
F: Send,
<F as Factory>::Handler: Send,
impl<F> !Sync for WebSocket<F>
impl<F> Unpin for WebSocket<F> where
F: Unpin,
<F as Factory>::Handler: Unpin,
F: Unpin,
<F as Factory>::Handler: Unpin,
impl<F> !UnwindSafe for WebSocket<F>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
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.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,