[−][src]Struct paperplane::Server
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]
&self,
map: F
) -> Result<()>
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]
self: &Arc<Self>,
map: F
) -> Result<()>
Loop through connections and kick the ones for which's id the given closure returns a reason.
Auto Trait Implementations
impl !RefUnwindSafe for Server
[src]
impl Send for Server
[src]
impl Sync for Server
[src]
impl Unpin for Server
[src]
impl !UnwindSafe for Server
[src]
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
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>,
V: MultiLane<T>,