Documentation
¶
Index ¶
- func NewRoomsPlugin() sdk.PluginProvider
- func SetGlobalHub(h *Hub)
- type Hub
- func (h *Hub) BroadcastToRoom(room string, msg []byte, excludeConnID string) int
- func (h *Hub) GetMembers(room string) []string
- func (h *Hub) JoinRoom(room, connID string) bool
- func (h *Hub) LeaveAllRooms(connID string)
- func (h *Hub) LeaveRoom(room, connID string)
- func (h *Hub) RegisterConnection(connID string)
- func (h *Hub) SetSendFunc(f func(connID string, msg []byte) bool)
- func (h *Hub) UnregisterConnection(connID string)
- type RoomHub
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRoomsPlugin ¶
func NewRoomsPlugin() sdk.PluginProvider
NewRoomsPlugin returns the rooms SDK plugin provider.
func SetGlobalHub ¶
func SetGlobalHub(h *Hub)
SetGlobalHub sets the global hub (called by the module on Init).
Types ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub implements RoomHub with a concurrent-safe room registry.
func GetGlobalHub ¶
func GetGlobalHub() *Hub
GetGlobalHub returns the global room hub once the rooms.manager module has initialized.
func (*Hub) BroadcastToRoom ¶
BroadcastToRoom sends msg to all connections in room (optionally excluding one). Returns the number of recipients that accepted the message.
func (*Hub) GetMembers ¶
GetMembers returns a list of connection IDs in the named room.
func (*Hub) JoinRoom ¶
JoinRoom adds connID to the named room. Returns true if the connection was registered.
func (*Hub) LeaveAllRooms ¶
LeaveAllRooms removes connID from every room it belongs to.
func (*Hub) RegisterConnection ¶
RegisterConnection registers a connection ID so it can join rooms.
func (*Hub) SetSendFunc ¶
SetSendFunc installs the function used by BroadcastToRoom to deliver messages.
func (*Hub) UnregisterConnection ¶
UnregisterConnection removes a connection from all rooms and cleans up.
type RoomHub ¶
type RoomHub interface {
JoinRoom(room, connID string) bool
LeaveRoom(room, connID string)
LeaveAllRooms(connID string)
BroadcastToRoom(room string, msg []byte, excludeConnID string) int
GetMembers(room string) []string
RegisterConnection(connID string)
UnregisterConnection(connID string)
}
RoomHub is the public interface for room management.