Documentation
¶
Index ¶
- func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request)
- type Client
- type Hub
- func (h *Hub) ProcessMessage(client *Client, messageType int, payload []byte) *Hub
- func (h *Hub) Run(serviceWG *sync.WaitGroup)
- func (h *Hub) RunSubscriptionService(sub *Subscription, exchangeName, product string, client *Client)
- func (h *Hub) Send(client *Client, message []byte)
- func (h *Hub) Subscribe(client *Client, exchange string, product string)
- func (h *Hub) Unsubscribe(client *Client)
- func (h *Hub) UnsubscribeAll()
- type Message
- type MessageResponse
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { // Unique client ID ID string `json:"id"` // contains filtered or unexported fields }
Client is a middleman between the websocket connection and the hub
type Hub ¶
type Hub struct { // Shutdown channel to stop the Hub Shutdown chan struct{} // Client subscriptions Subscriptions []*Subscription // Register channel for requests from the clients. Register chan *Client // Unregister channel for requests from clients. Unregister chan *Client // contains filtered or unexported fields }
Hub maintains the set of active clients and broadcasts messages to the clients.
func (*Hub) ProcessMessage ¶
func (*Hub) RunSubscriptionService ¶
func (h *Hub) RunSubscriptionService(sub *Subscription, exchangeName, product string, client *Client)
func (*Hub) Unsubscribe ¶
func (*Hub) UnsubscribeAll ¶
func (h *Hub) UnsubscribeAll()
type Message ¶
type Message struct { Action string `json:"action"` ExchangeID string `json:"exchange_id"` Message string `json:"message"` }
Message is the type for a valid message from a client
type MessageResponse ¶
type Subscription ¶
Subscription type holds a single client <-> exchange connection
Click to show internal directories.
Click to hide internal directories.