pub struct Server { /* private fields */ }
Expand description
A TCP WebSocket Server.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(cap: usize) -> Arc<Self>
pub fn new(cap: usize) -> Arc<Self>
Create a new Server
instance.
Takes a capacity for channel
and returns Arc<Server>
for convenience.
Sourcepub async fn connections(&self) -> Vec<u128>
pub async fn connections(&self) -> Vec<u128>
List connection ids.
Sourcepub async fn listen<A>(self: &Arc<Self>, addr: A) -> Result<()>where
A: ToSocketAddrs,
pub async fn listen<A>(self: &Arc<Self>, addr: A) -> Result<()>where
A: ToSocketAddrs,
Start listening on given socket address.
Sourcepub async fn close(self: &Arc<Self>) -> Result<()>
pub async fn close(self: &Arc<Self>) -> Result<()>
Close all connections and stop all listeners.
Sourcepub async fn next_transform<M>(
&self,
) -> Option<Result<Event<M>, <M as TryFrom<Message>>::Error>>
pub async fn next_transform<M>( &self, ) -> Option<Result<Event<M>, <M as TryFrom<Message>>::Error>>
Get next server event and try converting if it’s a Event::Message
.
Sourcepub async fn send<M>(&self, id: Option<u128>, msg: M) -> Result<()>
pub async fn send<M>(&self, id: Option<u128>, msg: M) -> Result<()>
Send a message to a connection with the given id.
If id is None
then the messages will be sent to all connections.
Auto Trait Implementations§
impl !Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more