Rooms
Neffos supports any number of rooms under a connected namespace.
Each connection connected to a namespace can join to one or more rooms.
Rooms are dynamic.
Server#Broadcast(Message {Namespace: ..., Room: ...})sends data to all clients connected to a specificNamespace:Room.Client and server can ask remote side to join to a room, get notified by
OnRoomJoinandOnRoomJoined.Client and server can ask remote side to leave from a room, get notified by
OnRoomLeaveandOnRoomLeft.Client and server can disallow remote request for room join through their
OnRoomJoin -> return err != nil.Client and server can disallow remote request for room leave through their
OnRoomLeave -> return err != nil.
// blocks until join in both sides.
room, err := nsConn.JoinRoom(ctx, "room")room.Emit("event", body)
// room.NSConn.Conn.Write(neffos.Message{
// Namespace: "namespace",
// Room: "room",
// Event: "event",
// Body: body,
// })room.Leave(ctx)Last updated