Documentation
¶
Index ¶
- type Manager
- func (m *Manager) Create(id, name string) *Room
- func (m *Manager) Delete(id string)
- func (m *Manager) Get(id string) (*Room, error)
- func (m *Manager) Join(roomID string, user core.User, conn ws.Conn) error
- func (m *Manager) JoinSession(roomID, sessionID string, user core.User, conn ws.Conn) error
- func (m *Manager) Leave(roomID, userID string) error
- func (m *Manager) List() []core.RoomInfo
- type Room
- func (r *Room) AddMember(user core.User, conn ws.Conn) error
- func (r *Room) AddMemberSession(sessionID string, user core.User, conn ws.Conn) error
- func (r *Room) Broadcast(ctx context.Context, senderSessionID string, data []byte) error
- func (r *Room) ID() string
- func (r *Room) MemberCount() int
- func (r *Room) Members() []core.User
- func (r *Room) Name() string
- func (r *Room) RemoveMember(sessionID string) error
- func (r *Room) Send(ctx context.Context, userID string, data []byte) error
- type UserSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple rooms.
func (*Manager) JoinSession ¶
JoinSession adds a specific session to a room, creating the room if it doesn't exist.
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
Room represents a communication room with members.
func (*Room) AddMemberSession ¶
AddMemberSession adds a device/session to the room while keeping room member metadata unique by user.
func (*Room) MemberCount ¶
MemberCount returns the number of members in the room.
func (*Room) RemoveMember ¶
RemoveMember removes a user from the room.
type UserSession ¶
type UserSession struct {
SessionID string
UserID string
Username string
DeviceID string
Conn ws.Conn
Rooms map[string]bool
Connected time.Time
// contains filtered or unexported fields
}
UserSession tracks a user's connection and joined rooms.
func NewDeviceSession ¶
func NewDeviceSession(sessionID, userID, username, deviceID string, conn ws.Conn) *UserSession
NewDeviceSession creates a new user session bound to a specific device/session identifier.
func NewUserSession ¶
func NewUserSession(userID, username string, conn ws.Conn) *UserSession
NewUserSession creates a new user session.
func (*UserSession) AddRoom ¶
func (s *UserSession) AddRoom(roomID string)
AddRoom tracks that the user joined a room.
func (*UserSession) RemoveRoom ¶
func (s *UserSession) RemoveRoom(roomID string)
RemoveRoom tracks that the user left a room.
func (*UserSession) RoomIDs ¶
func (s *UserSession) RoomIDs() []string
RoomIDs returns the list of rooms the user has joined.