Documentation
¶
Index ¶
- type Client
- type Event
- type EventType
- type Manager
- func (m *Manager) Authenticate(client *Client, userID string)
- func (m *Manager) Broadcast(eventType EventType, data interface{})
- func (m *Manager) GetConnectedClientsCount() int
- func (m *Manager) Register(client *Client)
- func (m *Manager) SendToUser(userID string, eventType EventType, data interface{})
- func (m *Manager) Start()
- func (m *Manager) Stop()
- func (m *Manager) Unregister(client *Client)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ID string Connection *websocket.Conn UserID string Subscribed map[EventType]bool Send chan Event LastActivity time.Time // contains filtered or unexported fields }
Client represents a connected websocket client
type Event ¶
type Event struct { Type EventType `json:"type"` Timestamp time.Time `json:"timestamp"` ID string `json:"id"` Data interface{} `json:"data"` }
Event represents a message sent over the websocket
type EventType ¶
type EventType string
EventType represents the type of event being sent over the websocket
const ( EventTypePing EventType = "ping" EventTypeServiceStatus EventType = "service_status" EventTypeTransaction EventType = "transaction" EventTypePriceFeed EventType = "price_feed" EventTypeTrigger EventType = "trigger" EventTypeFunction EventType = "function" EventTypeRandomNumber EventType = "random_number" EventTypeOracle EventType = "oracle" EventTypeNotification EventType = "notification" EventTypeError EventType = "error" )
Event types
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles websocket connections and broadcasts
func (*Manager) Authenticate ¶
Authenticate marks a client as authenticated
func (*Manager) GetConnectedClientsCount ¶
GetConnectedClientsCount returns the number of currently connected clients
func (*Manager) SendToUser ¶
SendToUser sends an event to a specific user
func (*Manager) Unregister ¶
Unregister removes a client
Click to show internal directories.
Click to hide internal directories.