MCPcopy Create free account
hub / github.com/Totodore/socketioxide / EngineIoHandler

Interface EngineIoHandler

crates/engineioxide/src/handler.rs:52–67  ·  view source on GitHub ↗

The [`EngineIoHandler`] trait can be implemented on any struct to handle socket events A `Data` associated type can be specified to attach a custom state to the sockets

Source from the content-addressed store, hash-verified

50///
51/// A `Data` associated type can be specified to attach a custom state to the sockets
52pub trait EngineIoHandler: std::fmt::Debug + Send + Sync + 'static {
53 /// Data associated with the socket.
54 type Data: Default + Send + Sync + 'static;
55
56 /// Called when a new socket is connected.
57 fn on_connect(self: Arc<Self>, socket: Arc<Socket<Self::Data>>);
58
59 /// Called when a socket is disconnected with a [`DisconnectReason`]
60 fn on_disconnect(&self, socket: Arc<Socket<Self::Data>>, reason: DisconnectReason);
61
62 /// Called when a message is received from the client.
63 fn on_message(self: &Arc<Self>, msg: Str, socket: Arc<Socket<Self::Data>>);
64
65 /// Called when a binary message is received from the client.
66 fn on_binary(self: &Arc<Self>, data: Bytes, socket: Arc<Socket<Self::Data>>);
67}

Callers

nothing calls this directly

Implementers 4

engine.rscrates/engineioxide/src/engine.rs
disconnect_reason.rscrates/engineioxide/tests/disconnect_r
client.rscrates/socketioxide/src/client.rs
engineioxide.rse2e/engineioxide/engineioxide.rs

Calls

no outgoing calls

Tested by

no test coverage detected