Trait socketioxide::adapter::Adapter

source ·
pub trait Adapter: Debug + Send + Sync + 'static {
    type Error: Error + Into<AdapterError> + Send + Sync + 'static;

Show 16 methods // Required methods fn new(ns: Weak<Namespace<Self>>) -> Self where Self: Sized; fn init(&self) -> Result<(), Self::Error>; fn close(&self) -> Result<(), Self::Error>; fn server_count(&self) -> Result<u16, Self::Error>; fn add_all( &self, sid: Sid, rooms: impl RoomParam ) -> Result<(), Self::Error>; fn del(&self, sid: Sid, rooms: impl RoomParam) -> Result<(), Self::Error>; fn del_all(&self, sid: Sid) -> Result<(), Self::Error>; fn broadcast( &self, packet: Packet<'_>, opts: BroadcastOptions ) -> Result<(), BroadcastError>; fn broadcast_with_ack( &self, packet: Packet<'static>, opts: BroadcastOptions, timeout: Option<Duration> ) -> AckInnerStream ; fn sockets(&self, rooms: impl RoomParam) -> Result<Vec<Sid>, Self::Error>; fn socket_rooms(&self, sid: Sid) -> Result<Vec<Room>, Self::Error>; fn fetch_sockets( &self, opts: BroadcastOptions ) -> Result<Vec<SocketRef<Self>>, Self::Error> where Self: Sized; fn add_sockets( &self, opts: BroadcastOptions, rooms: impl RoomParam ) -> Result<(), Self::Error>; fn del_sockets( &self, opts: BroadcastOptions, rooms: impl RoomParam ) -> Result<(), Self::Error>; fn disconnect_socket( &self, opts: BroadcastOptions ) -> Result<(), Vec<DisconnectError>>; fn rooms(&self) -> Result<Vec<Room>, Self::Error>;
}
Expand description

An adapter is responsible for managing the state of the server. This adapter can be implemented to share the state between multiple servers. The default adapter is the LocalAdapter, which stores the state in memory.

Required Associated Types§

source

type Error: Error + Into<AdapterError> + Send + Sync + 'static

An error that can occur when using the adapter. The default LocalAdapter has an Infallible error.

Required Methods§

source

fn new(ns: Weak<Namespace<Self>>) -> Self
where Self: Sized,

Create a new adapter and give the namespace ref to retrieve sockets.

source

fn init(&self) -> Result<(), Self::Error>

Initializes the adapter.

source

fn close(&self) -> Result<(), Self::Error>

Closes the adapter.

source

fn server_count(&self) -> Result<u16, Self::Error>

Returns the number of servers.

source

fn add_all(&self, sid: Sid, rooms: impl RoomParam) -> Result<(), Self::Error>

Adds the socket to all the rooms.

source

fn del(&self, sid: Sid, rooms: impl RoomParam) -> Result<(), Self::Error>

Removes the socket from the rooms.

source

fn del_all(&self, sid: Sid) -> Result<(), Self::Error>

Removes the socket from all the rooms.

source

fn broadcast( &self, packet: Packet<'_>, opts: BroadcastOptions ) -> Result<(), BroadcastError>

Broadcasts the packet to the sockets that match the BroadcastOptions.

source

fn broadcast_with_ack( &self, packet: Packet<'static>, opts: BroadcastOptions, timeout: Option<Duration> ) -> AckInnerStream

Broadcasts the packet to the sockets that match the BroadcastOptions and return a stream of ack responses.

source

fn sockets(&self, rooms: impl RoomParam) -> Result<Vec<Sid>, Self::Error>

Returns the sockets ids that match the BroadcastOptions.

source

fn socket_rooms(&self, sid: Sid) -> Result<Vec<Room>, Self::Error>

Returns the rooms of the socket.

source

fn fetch_sockets( &self, opts: BroadcastOptions ) -> Result<Vec<SocketRef<Self>>, Self::Error>
where Self: Sized,

Returns the sockets that match the BroadcastOptions.

source

fn add_sockets( &self, opts: BroadcastOptions, rooms: impl RoomParam ) -> Result<(), Self::Error>

Adds the sockets that match the BroadcastOptions to the rooms.

source

fn del_sockets( &self, opts: BroadcastOptions, rooms: impl RoomParam ) -> Result<(), Self::Error>

Removes the sockets that match the BroadcastOptions from the rooms.

source

fn disconnect_socket( &self, opts: BroadcastOptions ) -> Result<(), Vec<DisconnectError>>

Disconnects the sockets that match the BroadcastOptions.

source

fn rooms(&self) -> Result<Vec<Room>, Self::Error>

Returns all the rooms for this adapter.

Object Safety§

This trait is not object safe.

Implementors§