Documentation
¶
Index ¶
- func AddManager(manager *ConnectionManager, name string)
- func RemoveManager(name string)
- func SendEvent(managerName string, topic string, payload interface{}) error
- func SendEventToUser(managerName string, userID any, topic string, payload interface{}) error
- type Connection
- type ConnectionManager
- func (cm *ConnectionManager) AddClient(conn *Connection, userID any)
- func (cm *ConnectionManager) Broadcast(msg Message, sender *Connection)
- func (cm *ConnectionManager) GetConnectionsForUser(userID any) []*Connection
- func (cm *ConnectionManager) GetSubscribers(topic any) map[*Connection]bool
- func (cm *ConnectionManager) RemoveClient(conn *Connection, userID any)
- func (cm *ConnectionManager) SetDebug(enabled bool)
- func (cm *ConnectionManager) Subscribe(conn *Connection, topic string)
- func (cm *ConnectionManager) Unsubscribe(conn *Connection, topic string)
- type Message
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddManager ¶ added in v0.0.13
func AddManager(manager *ConnectionManager, name string)
func RemoveManager ¶ added in v0.0.13
func RemoveManager(name string)
RemoveManager removes a manager from the global managers map.
Types ¶
type Connection ¶
func NewConnection ¶
func NewConnection(conn net.Conn) *Connection
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
func GetManager ¶ added in v0.0.13
func GetManager(name string) *ConnectionManager
func NewConnectionManager ¶
func NewConnectionManager() *ConnectionManager
func (*ConnectionManager) AddClient ¶
func (cm *ConnectionManager) AddClient(conn *Connection, userID any)
func (*ConnectionManager) Broadcast ¶
func (cm *ConnectionManager) Broadcast(msg Message, sender *Connection)
func (*ConnectionManager) GetConnectionsForUser ¶ added in v0.0.13
func (cm *ConnectionManager) GetConnectionsForUser(userID any) []*Connection
GetConnectionsForUser retrieves all active connections for a given user ID.
func (*ConnectionManager) GetSubscribers ¶ added in v0.0.13
func (cm *ConnectionManager) GetSubscribers(topic any) map[*Connection]bool
GetSubscribers retrieves all connections subscribed to a given topic.
func (*ConnectionManager) RemoveClient ¶
func (cm *ConnectionManager) RemoveClient(conn *Connection, userID any)
func (*ConnectionManager) SetDebug ¶ added in v0.0.16
func (cm *ConnectionManager) SetDebug(enabled bool)
SetDebug enables or disables debug logging
func (*ConnectionManager) Subscribe ¶
func (cm *ConnectionManager) Subscribe(conn *Connection, topic string)
func (*ConnectionManager) Unsubscribe ¶ added in v0.0.13
func (cm *ConnectionManager) Unsubscribe(conn *Connection, topic string)
type Message ¶
type Message struct {
ID string `json:"id"`
Topic string `json:"topic"`
Payload json.RawMessage `json:"payload"`
Sender *Connection `json:"-"`
}
Click to show internal directories.
Click to hide internal directories.