[][src]Struct paperplane::Server

pub struct Server { /* fields omitted */ }

A TCP WebSocket Server.

Implementations

impl Server[src]

pub fn new(cap: usize) -> Arc<Self>[src]

Create a new Server instance. Takes channel capacity and returns Arc<Server> for convenience. Channel is currently created with futures::channel::mpsc::channel but might be with async_std::channel::bounded in the future.

pub async fn accept(self: &Arc<Self>, stream: TcpStream) -> Result<u128>[src]

Accept given TcpStream as a WebSocket connection.

pub async fn listen<A: ToSocketAddrs>(self: &Arc<Self>, addr: A) -> Result<()>[src]

Start listening on given socket address.

pub async fn close(self: &Arc<Self>) -> Result<()>[src]

Close all connections and stop all listeners.

pub async fn next(&self) -> Option<Event>[src]

Get next server event.

pub async fn send(&self, id: u128, msg: Message) -> Result<()>[src]

Send a message to a connection with the given id.

pub async fn send_all(&self, msg: Message) -> Result<()>[src]

Send a message to all current connections.

pub async fn send_map<F: Fn(u128) -> Option<Message>>(
    &self,
    map: F
) -> Result<()>
[src]

Loop through connections and send messages determined by the given closure.

pub async fn kick(&self, id: u128, reason: &str) -> Result<()>[src]

Close a connection with the given id and reason.

pub async fn kick_all(self: &Arc<Self>, reason: &str) -> Result<()>[src]

Close all current connections with the given reason.

pub async fn kick_map<F: Fn(u128) -> Option<String>>(
    self: &Arc<Self>,
    map: F
) -> Result<()>
[src]

Loop through connections and kick the ones for which's id the given closure returns a reason.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,