-
-
Notifications
You must be signed in to change notification settings - Fork 49
Rooms
Gerasimos (Makis) Maropoulos edited this page Jul 1, 2019
·
4 revisions
Neffos supports unlimited 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
OnRoomJoin
andOnRoomJoined
. - Client and server can ask remote side to leave from a room, get notified by
OnRoomLeave
andOnRoomLeft
. - 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)
Home | About | Project | Getting Started | Technical Docs | Copyright © 2019-2023 Gerasimos Maropoulos. Documentation terms of use.