Emitting events
Server → Client
You emit events from the server using sendEvent().
client.sendEvent("message", "Hello from server");client:
SocketIOClientinstance."message": event name.
payload: object that will be serialized to the client (JSON allowed).
Emitting with multiple objects:
client.sendEvent("update", user, metadata);You can emit from anywhere you hold a SocketIOClient, for example inside a listener.
Client → Server
From the client (JavaScript):
socket.emit("chat", { text:"Hi world" });Last updated
Was this helpful?