internal

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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 NewHub

func NewHub() *Hub

NewHub creates a new room hub.

func (*Hub) BroadcastToRoom

func (h *Hub) BroadcastToRoom(room string, msg []byte, excludeConnID string) int

BroadcastToRoom sends msg to all connections in room (optionally excluding one). Returns the number of recipients that accepted the message.

func (*Hub) GetMembers

func (h *Hub) GetMembers(room string) []string

GetMembers returns a list of connection IDs in the named room.

func (*Hub) JoinRoom

func (h *Hub) JoinRoom(room, connID string) bool

JoinRoom adds connID to the named room. Returns true if the connection was registered.

func (*Hub) LeaveAllRooms

func (h *Hub) LeaveAllRooms(connID string)

LeaveAllRooms removes connID from every room it belongs to.

func (*Hub) LeaveRoom

func (h *Hub) LeaveRoom(room, connID string)

LeaveRoom removes connID from the named room.

func (*Hub) RegisterConnection

func (h *Hub) RegisterConnection(connID string)

RegisterConnection registers a connection ID so it can join rooms.

func (*Hub) SetSendFunc

func (h *Hub) SetSendFunc(f func(connID string, msg []byte) bool)

SetSendFunc installs the function used by BroadcastToRoom to deliver messages.

func (*Hub) UnregisterConnection

func (h *Hub) UnregisterConnection(connID string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL