Documentation ¶
Index ¶
- type Connection
- type ConnectionStatus
- type Hub
- func (h *Hub) AddConnection(name string, soc *Connection)
- func (h *Hub) Broadcast(topic string, event []byte)
- func (h *Hub) GetConnection(name string) *Connection
- func (h *Hub) GetSubscriptions(conn string) []string
- func (h *Hub) RemoveConnection(name string)
- func (h *Hub) Subscribe(conn string, topic string) error
- func (h *Hub) UnSubscribe(conn string, topic string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { ConnMu sync.Mutex ConnectionId string Status ConnectionStatus Conn *websocket.Conn ConnectedAt time.Time DisconnectedAt time.Time }
func (*Connection) SendMessage ¶
func (s *Connection) SendMessage(messageType int, message []byte) error
type ConnectionStatus ¶
type ConnectionStatus uint8
const ( ALIVE ConnectionStatus = 0 CLOSED ConnectionStatus = 1 )
type Hub ¶
type Hub struct { Mu sync.Mutex AvailableTopics map[string]bool Connections map[string]*Connection UpgradedSubs map[string]map[string]struct{} // using struct, it consumes 0 bytes }
func (*Hub) AddConnection ¶
func (h *Hub) AddConnection(name string, soc *Connection)
func (*Hub) GetConnection ¶
func (h *Hub) GetConnection(name string) *Connection
func (*Hub) GetSubscriptions ¶
func (*Hub) RemoveConnection ¶
func (*Hub) UnSubscribe ¶
Click to show internal directories.
Click to hide internal directories.