Documentation ¶
Index ¶
- Constants
- func ConnectionEndpoint(w http.ResponseWriter, r *http.Request)
- func DepositSocketUnsubscribeHandler(a common.Address) func(client *Client)
- func OrderSocketUnsubscribeHandler(a common.Address) func(client *Client)
- func RegisterChannel(channel string, fn func(interface{}, *Client)) error
- func RegisterConnectionUnsubscribeHandler(c *Client, fn func(*Client))
- func RegisterDepositConnection(a common.Address, c *Client)
- func RegisterOrderConnection(a common.Address, c *Client)
- func SendDepositMessage(msgType types.SubscriptionEvent, a common.Address, payload interface{})
- func SendOrderMessage(msgType types.SubscriptionEvent, a common.Address, payload interface{})
- type Client
- type DepositConnection
- type OHLCVSocket
- func (s *OHLCVSocket) BroadcastOHLCV(channelID string, p interface{}) error
- func (s *OHLCVSocket) SendErrorMessage(c *Client, p interface{})
- func (s *OHLCVSocket) SendInitMessage(c *Client, p interface{})
- func (s *OHLCVSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
- func (s *OHLCVSocket) SendUpdateMessage(c *Client, p interface{})
- func (s *OHLCVSocket) Subscribe(channelID string, c *Client) error
- func (s *OHLCVSocket) Unsubscribe(c *Client)
- func (s *OHLCVSocket) UnsubscribeChannel(channelID string, c *Client)
- func (s *OHLCVSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
- func (s *OHLCVSocket) UnsubscribeHandler() func(c *Client)
- type OrderBookSocket
- func (s *OrderBookSocket) BroadcastMessage(channelID string, p interface{}) error
- func (s *OrderBookSocket) SendErrorMessage(c *Client, data interface{})
- func (s *OrderBookSocket) SendInitMessage(c *Client, data interface{})
- func (s *OrderBookSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
- func (s *OrderBookSocket) SendUpdateMessage(c *Client, data interface{})
- func (s *OrderBookSocket) Subscribe(channelID string, c *Client) error
- func (s *OrderBookSocket) Unsubscribe(c *Client)
- func (s *OrderBookSocket) UnsubscribeChannel(channelID string, c *Client)
- func (s *OrderBookSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
- func (s *OrderBookSocket) UnsubscribeHandler() func(c *Client)
- type OrderConnection
- type PriceBoardSocket
- func (s *PriceBoardSocket) BroadcastMessage(channelID string, p interface{}) error
- func (s *PriceBoardSocket) SendErrorMessage(c *Client, data interface{})
- func (s *PriceBoardSocket) SendInitMessage(c *Client, data interface{})
- func (s *PriceBoardSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
- func (s *PriceBoardSocket) SendUpdateMessage(c *Client, data interface{})
- func (s *PriceBoardSocket) Subscribe(channelID string, c *Client) error
- func (s *PriceBoardSocket) Unsubscribe(c *Client)
- func (s *PriceBoardSocket) UnsubscribeChannel(channelID string, c *Client)
- func (s *PriceBoardSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
- func (s *PriceBoardSocket) UnsubscribeHandler() func(c *Client)
- type RawOrderBookSocket
- func (s *RawOrderBookSocket) BroadcastMessage(channelID string, p interface{}) error
- func (s *RawOrderBookSocket) SendErrorMessage(c *Client, data interface{})
- func (s *RawOrderBookSocket) SendInitMessage(c *Client, data interface{})
- func (s *RawOrderBookSocket) SendUpdateMessage(c *Client, data interface{})
- func (s *RawOrderBookSocket) Subscribe(channelID string, c *Client) error
- func (s *RawOrderBookSocket) Unsubscribe(c *Client)
- func (s *RawOrderBookSocket) UnsubscribeChannel(channelID string, c *Client)
- func (s *RawOrderBookSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
- func (s *RawOrderBookSocket) UnsubscribeHandler() func(c *Client)
- type TradeSocket
- func (s *TradeSocket) BroadcastMessage(channelID string, p interface{})
- func (s *TradeSocket) SendErrorMessage(c *Client, p interface{})
- func (s *TradeSocket) SendInitMessage(c *Client, p interface{})
- func (s *TradeSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
- func (s *TradeSocket) SendUpdateMessage(c *Client, p interface{})
- func (s *TradeSocket) Subscribe(channelID string, c *Client) error
- func (s *TradeSocket) Unsubscribe(c *Client)
- func (s *TradeSocket) UnsubscribeChannel(channelID string, c *Client)
- func (s *TradeSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
- func (s *TradeSocket) UnsubscribeHandler() func(c *Client)
- type WebsocketLogger
Constants ¶
const ( TradeChannel = "trades" RawOrderBookChannel = "raw_orderbook" OrderChannel = "orders" OrderBookChannel = "orderbook" TokenChannel = "tokens" OHLCVChannel = "ohlcv" PriceBoardChannel = "price_board" DepositChannel = "deposit" )
Variables ¶
This section is empty.
Functions ¶
func ConnectionEndpoint ¶
func ConnectionEndpoint(w http.ResponseWriter, r *http.Request)
ConnectionEndpoint is the the handleFunc function for websocket connections It handles incoming websocket messages and routes the message according to channel parameter in channelMessage
func RegisterChannel ¶
func RegisterConnectionUnsubscribeHandler ¶
RegisterConnectionUnsubscribeHandler needs to be called whenever a connection subscribes to a new channel. At the time of connection closing the ConnectionUnsubscribeHandler handlers associated with that connection are triggered.
func RegisterDepositConnection ¶
RegisterDepositConnection registers a connection with and depositID. It is called whenever a message is recieved over deposit channel
func RegisterOrderConnection ¶
RegisterOrderConnection registers a connection with and orderID. It is called whenever a message is recieved over order channel
func SendDepositMessage ¶
func SendDepositMessage(msgType types.SubscriptionEvent, a common.Address, payload interface{})
func SendOrderMessage ¶
func SendOrderMessage(msgType types.SubscriptionEvent, a common.Address, payload interface{})
Types ¶
type Client ¶
func (*Client) SendMessage ¶
func (c *Client) SendMessage(channel string, msgType types.SubscriptionEvent, payload interface{}, h ...common.Hash)
SendMessage constructs the message with proper structure to be sent over websocket
type DepositConnection ¶
type DepositConnection []*Client
Send update directly to client based on wallet address
func GetDepositConnections ¶
func GetDepositConnections(a common.Address) DepositConnection
GetDepositConn returns the connection associated with an deposit ID
type OHLCVSocket ¶
type OHLCVSocket struct {
// contains filtered or unexported fields
}
OHLCVSocket holds the map of subscribtions subscribed to OHLCV channels corresponding to the key/event they have subscribed to.
func GetOHLCVSocket ¶
func GetOHLCVSocket() *OHLCVSocket
GetOHLCVSocket return singleton instance of OHLCVSocket type struct
func NewOHLCVSocket ¶
func NewOHLCVSocket() *OHLCVSocket
func (*OHLCVSocket) BroadcastOHLCV ¶
func (s *OHLCVSocket) BroadcastOHLCV(channelID string, p interface{}) error
BroadcastOHLCV Message streams message to all the subscriptions subscribed to the pair
func (*OHLCVSocket) SendErrorMessage ¶
func (s *OHLCVSocket) SendErrorMessage(c *Client, p interface{})
SendErrorMessage sends an error message on the trade channel
func (*OHLCVSocket) SendInitMessage ¶
func (s *OHLCVSocket) SendInitMessage(c *Client, p interface{})
SendInitMessage is responsible for sending message on trade channel at subscription
func (*OHLCVSocket) SendMessage ¶
func (s *OHLCVSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
SendMessage sends a websocket message on the trade channel
func (*OHLCVSocket) SendUpdateMessage ¶
func (s *OHLCVSocket) SendUpdateMessage(c *Client, p interface{})
SendUpdateMessage is responsible for sending message on trade channel at subscription
func (*OHLCVSocket) Subscribe ¶
func (s *OHLCVSocket) Subscribe(channelID string, c *Client) error
Subscribe handles the registration of connection to get streaming data over the socket for any pair.
func (*OHLCVSocket) Unsubscribe ¶
func (s *OHLCVSocket) Unsubscribe(c *Client)
func (*OHLCVSocket) UnsubscribeChannel ¶
func (s *OHLCVSocket) UnsubscribeChannel(channelID string, c *Client)
Unsubscribe is used to unsubscribe the connection from listening to the key subscribed to. It can be called on unsubscription message from user or due to some other reason by system
func (*OHLCVSocket) UnsubscribeChannelHandler ¶
func (s *OHLCVSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
UnsubscribeHandler returns function of type unsubscribe handler, it handles the unsubscription of pair in case of connection closing.
func (*OHLCVSocket) UnsubscribeHandler ¶
func (s *OHLCVSocket) UnsubscribeHandler() func(c *Client)
type OrderBookSocket ¶
type OrderBookSocket struct {
// contains filtered or unexported fields
}
OrderBookSocket holds the map of subscriptions subscribed to orderbook channels corresponding to the key/event they have subscribed to.
func GetOrderBookSocket ¶
func GetOrderBookSocket() *OrderBookSocket
GetOrderBookSocket return singleton instance of OrderBookSocket type struct
func NewOrderBookSocket ¶
func NewOrderBookSocket() *OrderBookSocket
func (*OrderBookSocket) BroadcastMessage ¶
func (s *OrderBookSocket) BroadcastMessage(channelID string, p interface{}) error
BroadcastMessage streams message to all the subscribtions subscribed to the pair
func (*OrderBookSocket) SendErrorMessage ¶
func (s *OrderBookSocket) SendErrorMessage(c *Client, data interface{})
SendErrorMessage sends error message on orderbook channel
func (*OrderBookSocket) SendInitMessage ¶
func (s *OrderBookSocket) SendInitMessage(c *Client, data interface{})
SendInitMessage sends INIT message on orderbook channel on subscription event
func (*OrderBookSocket) SendMessage ¶
func (s *OrderBookSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
SendMessage sends a websocket message on the orderbook channel
func (*OrderBookSocket) SendUpdateMessage ¶
func (s *OrderBookSocket) SendUpdateMessage(c *Client, data interface{})
SendUpdateMessage sends UPDATE message on orderbook channel as new data is created
func (*OrderBookSocket) Subscribe ¶
func (s *OrderBookSocket) Subscribe(channelID string, c *Client) error
Subscribe handles the subscription of connection to get streaming data over the socker for any pair. pair := utils.GetPairKey(bt, qt)
func (*OrderBookSocket) Unsubscribe ¶
func (s *OrderBookSocket) Unsubscribe(c *Client)
func (*OrderBookSocket) UnsubscribeChannel ¶
func (s *OrderBookSocket) UnsubscribeChannel(channelID string, c *Client)
Unsubscribe removes a websocket connection from the orderbook channel updates
func (*OrderBookSocket) UnsubscribeChannelHandler ¶
func (s *OrderBookSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
UnsubscribeHandler unsubscribes a connection from a certain orderbook channel id
func (*OrderBookSocket) UnsubscribeHandler ¶
func (s *OrderBookSocket) UnsubscribeHandler() func(c *Client)
type OrderConnection ¶
type OrderConnection []*Client
func GetOrderConnections ¶
func GetOrderConnections(a common.Address) OrderConnection
GetOrderConn returns the connection associated with an order ID
type PriceBoardSocket ¶
type PriceBoardSocket struct {
// contains filtered or unexported fields
}
PriceBoardSocket holds the map of subscriptions subscribed to price board channels corresponding to the key/event they have subscribed to.
func GetPriceBoardSocket ¶
func GetPriceBoardSocket() *PriceBoardSocket
GetPriceBoardSocket return singleton instance of PriceBoardSocket type struct
func NewPriceBoardSocket ¶
func NewPriceBoardSocket() *PriceBoardSocket
func (*PriceBoardSocket) BroadcastMessage ¶
func (s *PriceBoardSocket) BroadcastMessage(channelID string, p interface{}) error
BroadcastMessage streams message to all the subscriptions subscribed to the pair
func (*PriceBoardSocket) SendErrorMessage ¶
func (s *PriceBoardSocket) SendErrorMessage(c *Client, data interface{})
SendErrorMessage sends error message on price board channel
func (*PriceBoardSocket) SendInitMessage ¶
func (s *PriceBoardSocket) SendInitMessage(c *Client, data interface{})
SendInitMessage sends INIT message on price board channel on subscription event
func (*PriceBoardSocket) SendMessage ¶
func (s *PriceBoardSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
SendMessage sends a websocket message on the price board channel
func (*PriceBoardSocket) SendUpdateMessage ¶
func (s *PriceBoardSocket) SendUpdateMessage(c *Client, data interface{})
SendUpdateMessage sends UPDATE message on price board channel as new data is created
func (*PriceBoardSocket) Subscribe ¶
func (s *PriceBoardSocket) Subscribe(channelID string, c *Client) error
Subscribe handles the subscription of connection to get streaming data over the socker for any pair.
func (*PriceBoardSocket) Unsubscribe ¶
func (s *PriceBoardSocket) Unsubscribe(c *Client)
func (*PriceBoardSocket) UnsubscribeChannel ¶
func (s *PriceBoardSocket) UnsubscribeChannel(channelID string, c *Client)
Unsubscribe removes a websocket connection from the price board channel updates
func (*PriceBoardSocket) UnsubscribeChannelHandler ¶
func (s *PriceBoardSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
UnsubscribeHandler unsubscribes a connection from a certain price board channel id
func (*PriceBoardSocket) UnsubscribeHandler ¶
func (s *PriceBoardSocket) UnsubscribeHandler() func(c *Client)
type RawOrderBookSocket ¶
type RawOrderBookSocket struct {
// contains filtered or unexported fields
}
RawOrderBookSocket holds the map of subscribtions subscribed to pair channels corresponding to the key/event they have subscribed to.
func GetRawOrderBookSocket ¶
func GetRawOrderBookSocket() *RawOrderBookSocket
GetRawOrderBookSocket return singleton instance of PairSockets type struct
func NewRawOrderBookSocket ¶
func NewRawOrderBookSocket() *RawOrderBookSocket
func (*RawOrderBookSocket) BroadcastMessage ¶
func (s *RawOrderBookSocket) BroadcastMessage(channelID string, p interface{}) error
BroadcastMessage streams message to all the subscribtions subscribed to the pair
func (*RawOrderBookSocket) SendErrorMessage ¶
func (s *RawOrderBookSocket) SendErrorMessage(c *Client, data interface{})
func (*RawOrderBookSocket) SendInitMessage ¶
func (s *RawOrderBookSocket) SendInitMessage(c *Client, data interface{})
SendInitMessage sends INIT message on orderbookchannel on subscription event
func (*RawOrderBookSocket) SendUpdateMessage ¶
func (s *RawOrderBookSocket) SendUpdateMessage(c *Client, data interface{})
SendUpdateMessage sends UPDATE message on orderbookchannel as new data is created
func (*RawOrderBookSocket) Subscribe ¶
func (s *RawOrderBookSocket) Subscribe(channelID string, c *Client) error
Subscribe handles the subscription of connection to get streaming data over the socker for any pair. pair := utils.GetPairKey(bt, qt)
func (*RawOrderBookSocket) Unsubscribe ¶
func (s *RawOrderBookSocket) Unsubscribe(c *Client)
func (*RawOrderBookSocket) UnsubscribeChannel ¶
func (s *RawOrderBookSocket) UnsubscribeChannel(channelID string, c *Client)
Unsubscribe is used to unsubscribe the connection from listening to the key subscribed to. It can be called on unsubscription message from user or due to some other reason by system
func (*RawOrderBookSocket) UnsubscribeChannelHandler ¶
func (s *RawOrderBookSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
UnsubscribeHandler returns function of type unsubscribe handler, it handles the unsubscription of pair in case of connection closing.
func (*RawOrderBookSocket) UnsubscribeHandler ¶
func (s *RawOrderBookSocket) UnsubscribeHandler() func(c *Client)
type TradeSocket ¶
type TradeSocket struct {
// contains filtered or unexported fields
}
TradeSocket holds the map of connections subscribed to pair channels corresponding to the key/event they have subscribed to.
func GetTradeSocket ¶
func GetTradeSocket() *TradeSocket
func NewTradeSocket ¶
func NewTradeSocket() *TradeSocket
func (*TradeSocket) BroadcastMessage ¶
func (s *TradeSocket) BroadcastMessage(channelID string, p interface{})
BroadcastMessage broadcasts trade message to all subscribed sockets
func (*TradeSocket) SendErrorMessage ¶
func (s *TradeSocket) SendErrorMessage(c *Client, p interface{})
SendErrorMessage sends an error message on the trade channel
func (*TradeSocket) SendInitMessage ¶
func (s *TradeSocket) SendInitMessage(c *Client, p interface{})
SendInitMessage is responsible for sending message on trade ohlcv channel at subscription
func (*TradeSocket) SendMessage ¶
func (s *TradeSocket) SendMessage(c *Client, msgType types.SubscriptionEvent, p interface{})
SendMessage sends a websocket message on the trade channel
func (*TradeSocket) SendUpdateMessage ¶
func (s *TradeSocket) SendUpdateMessage(c *Client, p interface{})
SendUpdateMessage is responsible for sending message on trade ohlcv channel at subscription
func (*TradeSocket) Subscribe ¶
func (s *TradeSocket) Subscribe(channelID string, c *Client) error
Subscribe registers a new websocket connections to the trade channel updates
func (*TradeSocket) Unsubscribe ¶
func (s *TradeSocket) Unsubscribe(c *Client)
func (*TradeSocket) UnsubscribeChannel ¶
func (s *TradeSocket) UnsubscribeChannel(channelID string, c *Client)
Unsubscribe removes a websocket connection from the trade channel updates
func (*TradeSocket) UnsubscribeChannelHandler ¶
func (s *TradeSocket) UnsubscribeChannelHandler(channelID string) func(c *Client)
UnsubscribeHandler unsubscribes a connection from a certain trade channel id
func (*TradeSocket) UnsubscribeHandler ¶
func (s *TradeSocket) UnsubscribeHandler() func(c *Client)
type WebsocketLogger ¶
func NewWebsocketLogger ¶
func NewWebsocketLogger() *WebsocketLogger
func (*WebsocketLogger) LogMessageIn ¶
func (l *WebsocketLogger) LogMessageIn(msg *types.WebsocketMessage)
func (*WebsocketLogger) LogMessageOut ¶
func (l *WebsocketLogger) LogMessageOut(msg *types.WebsocketMessage)