Struct thruster_socketio::SocketIO
source · pub struct SocketIO { /* private fields */ }
Implementations§
source§impl SocketIOSocket
impl SocketIOSocket
pub fn new(id: String, sender: Sender<InternalMessage>) -> Self
sourcepub fn use_handler(
&self,
_handler: fn(_: SocketIOSocket, _: String) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send>>
)
pub fn use_handler( &self, _handler: fn(_: SocketIOSocket, _: String) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send>> )
use_handler isn’t implemented yet.
sourcepub fn on(
&mut self,
event: &str,
handler: fn(_: SocketIOSocket, _: String) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send>>
)
pub fn on( &mut self, event: &str, handler: fn(_: SocketIOSocket, _: String) -> Pin<Box<dyn Future<Output = Result<(), ()>> + Send>> )
on adds a listener for a particular event
sourcepub async fn join(&mut self, room_id: &str)
pub async fn join(&mut self, room_id: &str)
join joins a socket into a room. This makes every message sent by that socket go to the room rather than globally.
sourcepub async fn leave(&mut self, room_id: &str)
pub async fn leave(&mut self, room_id: &str)
leave removes a socket from a room. Note that you cannot remove a socket from its default room, i.e. its SID. This will result in a noop.
sourcepub async fn emit_to(&self, room_id: &str, event: &str, message: &str)
pub async fn emit_to(&self, room_id: &str, event: &str, message: &str)
emit_to sends a message to all sockets connected to the given room_id, including the sending socket.
sourcepub async fn broadcast_to(&self, room_id: &str, event: &str, message: &str)
pub async fn broadcast_to(&self, room_id: &str, event: &str, message: &str)
broadcast_to sends a message to all the sockets connected to the given room_id, excluding the sending socket.