pub trait SocketEmitter:
Send
+ Sync
+ 'static {
type AckError: StdError + Send + Serialize + DeserializeOwned + 'static;
type AckStream: Stream<Item = AckStreamItem<Self::AckError>> + FusedStream + Send + 'static;
// Required methods
fn get_all_sids(&self, filter: impl Fn(&Sid) -> bool) -> Vec<Sid>;
fn get_remote_sockets(
&self,
sids: BroadcastIter<'_>,
) -> Vec<RemoteSocketData>;
fn send_many(
&self,
sids: BroadcastIter<'_>,
data: Value,
) -> Result<(), Vec<SocketError>>;
fn send_many_with_ack(
&self,
sids: BroadcastIter<'_>,
packet: Packet,
timeout: Option<Duration>,
) -> (Self::AckStream, u32);
fn disconnect_many(&self, sids: Vec<Sid>) -> Result<(), Vec<SocketError>>;
fn path(&self) -> &Str;
fn parser(&self) -> impl Parse;
fn server_id(&self) -> Uid;
}
Expand description
The SocketEmitter
will be implemented by the socketioxide library.
It is simply used as an abstraction to allow the adapter to communicate
with the socket server without the need to depend on the socketioxide lib.
Required Associated Types§
Sourcetype AckError: StdError + Send + Serialize + DeserializeOwned + 'static
type AckError: StdError + Send + Serialize + DeserializeOwned + 'static
An error that can occur when sending data an acknowledgment.
Sourcetype AckStream: Stream<Item = AckStreamItem<Self::AckError>> + FusedStream + Send + 'static
type AckStream: Stream<Item = AckStreamItem<Self::AckError>> + FusedStream + Send + 'static
A stream that emits the acknowledgments of multiple sockets.
Required Methods§
Sourcefn get_all_sids(&self, filter: impl Fn(&Sid) -> bool) -> Vec<Sid>
fn get_all_sids(&self, filter: impl Fn(&Sid) -> bool) -> Vec<Sid>
Get all the socket ids in the namespace.
Sourcefn get_remote_sockets(&self, sids: BroadcastIter<'_>) -> Vec<RemoteSocketData>
fn get_remote_sockets(&self, sids: BroadcastIter<'_>) -> Vec<RemoteSocketData>
Get the socket data that match the list of socket ids.
Sourcefn send_many(
&self,
sids: BroadcastIter<'_>,
data: Value,
) -> Result<(), Vec<SocketError>>
fn send_many( &self, sids: BroadcastIter<'_>, data: Value, ) -> Result<(), Vec<SocketError>>
Send data to the list of socket ids.
Sourcefn send_many_with_ack(
&self,
sids: BroadcastIter<'_>,
packet: Packet,
timeout: Option<Duration>,
) -> (Self::AckStream, u32)
fn send_many_with_ack( &self, sids: BroadcastIter<'_>, packet: Packet, timeout: Option<Duration>, ) -> (Self::AckStream, u32)
Send data to the list of socket ids and get a stream of acks and the number of expected acks.
Sourcefn disconnect_many(&self, sids: Vec<Sid>) -> Result<(), Vec<SocketError>>
fn disconnect_many(&self, sids: Vec<Sid>) -> Result<(), Vec<SocketError>>
Disconnect all the sockets in the list.
TODO: take a BroadcastIter
. Currently it is impossible because it may create deadlocks
with Adapter::del_all call.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.