Documentation ¶
Index ¶
- Constants
- func ConnectionEndpoint(w http.ResponseWriter, r *http.Request)
- 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 RegisterOrderConnection(a common.Address, c *Client)
- func SendOrderMessage(msgType string, a common.Address, payload interface{})
- type Client
- 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 string, 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) 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) UnsubscribeHandler(channelID string) func(c *Client)
- type OrderConnection
- 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 string, 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" OHLCVChannel = "ohlcv" )
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 RegisterOrderConnection ¶
RegisterOrderConnection registers a connection with and orderID. It is called whenever a message is recieved over order channel
func SendOrderMessage ¶
Types ¶
type Client ¶
func (*Client) SendMessage ¶
SendMessage constructs the message with proper structure to be sent over websocket
type OHLCVSocket ¶
type OHLCVSocket struct {
// contains filtered or unexported fields
}
OHLCVSocket holds the map of subscribtions subscribed to pair channels corresponding to the key/event they have subscribed to.
func GetOHLCVSocket ¶
func GetOHLCVSocket() *OHLCVSocket
GetOHLCVSocket return singleton instance of PairSockets 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 subscribtions 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 ohlcv channel at subscription
func (*OHLCVSocket) SendMessage ¶
func (s *OHLCVSocket) SendMessage(c *Client, msgType string, 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 ohlcv 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 socker 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 subscribtions subscribed to pair channels corresponding to the key/event they have subscribed to.
func GetOrderBookSocket ¶
func GetOrderBookSocket() *OrderBookSocket
GetOrderBookSocket return singleton instance of PairSockets 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 orderbookchannel
func (*OrderBookSocket) SendInitMessage ¶
func (s *OrderBookSocket) SendInitMessage(c *Client, data interface{})
SendInitMessage sends INIT message on orderbookchannel on subscription event
func (*OrderBookSocket) SendUpdateMessage ¶
func (s *OrderBookSocket) SendUpdateMessage(c *Client, data interface{})
SendUpdateMessage sends UPDATE message on orderbookchannel 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 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 (*OrderBookSocket) UnsubscribeHandler ¶
func (s *OrderBookSocket) UnsubscribeHandler(channelID string) func(c *Client)
UnsubscribeHandler returns function of type unsubscribe handler, it handles the unsubscription of pair in case of connection closing.
type OrderConnection ¶
type OrderConnection []*Client
func GetOrderConnections ¶
func GetOrderConnections(a common.Address) OrderConnection
GetOrderConn returns the connection associated with an order ID
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 string, 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)