2020-10-01 08:48:08 +00:00
|
|
|
// Code generated by "callbackgen -type WebSocketService"; DO NOT EDIT.
|
2020-10-01 08:07:18 +00:00
|
|
|
|
|
|
|
package max
|
|
|
|
|
2020-10-02 04:43:14 +00:00
|
|
|
import (
|
|
|
|
"github.com/gorilla/websocket"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *WebSocketService) OnConnect(cb func(conn *websocket.Conn)) {
|
|
|
|
s.connectCallbacks = append(s.connectCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *WebSocketService) EmitConnect(conn *websocket.Conn) {
|
|
|
|
for _, cb := range s.connectCallbacks {
|
|
|
|
cb(conn)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *WebSocketService) OnDisconnect(cb func(conn *websocket.Conn)) {
|
|
|
|
s.disconnectCallbacks = append(s.disconnectCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *WebSocketService) EmitDisconnect(conn *websocket.Conn) {
|
|
|
|
for _, cb := range s.disconnectCallbacks {
|
|
|
|
cb(conn)
|
|
|
|
}
|
|
|
|
}
|
2020-10-01 08:07:18 +00:00
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) OnError(cb func(err error)) {
|
2020-10-01 08:07:18 +00:00
|
|
|
s.errorCallbacks = append(s.errorCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) EmitError(err error) {
|
2020-10-01 08:07:18 +00:00
|
|
|
for _, cb := range s.errorCallbacks {
|
|
|
|
cb(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) OnMessage(cb func(message []byte)) {
|
2020-10-01 08:07:18 +00:00
|
|
|
s.messageCallbacks = append(s.messageCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) EmitMessage(message []byte) {
|
2020-10-01 08:07:18 +00:00
|
|
|
for _, cb := range s.messageCallbacks {
|
|
|
|
cb(message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) OnBookEvent(cb func(e BookEvent)) {
|
2020-10-01 08:07:18 +00:00
|
|
|
s.bookEventCallbacks = append(s.bookEventCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) EmitBookEvent(e BookEvent) {
|
2020-10-01 08:07:18 +00:00
|
|
|
for _, cb := range s.bookEventCallbacks {
|
|
|
|
cb(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) OnTradeEvent(cb func(e TradeEvent)) {
|
2020-10-01 08:07:18 +00:00
|
|
|
s.tradeEventCallbacks = append(s.tradeEventCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) EmitTradeEvent(e TradeEvent) {
|
2020-10-01 08:07:18 +00:00
|
|
|
for _, cb := range s.tradeEventCallbacks {
|
|
|
|
cb(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) OnErrorEvent(cb func(e ErrorEvent)) {
|
2020-10-01 08:07:18 +00:00
|
|
|
s.errorEventCallbacks = append(s.errorEventCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) EmitErrorEvent(e ErrorEvent) {
|
2020-10-01 08:07:18 +00:00
|
|
|
for _, cb := range s.errorEventCallbacks {
|
|
|
|
cb(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) OnSubscriptionEvent(cb func(e SubscriptionEvent)) {
|
2020-10-01 08:07:18 +00:00
|
|
|
s.subscriptionEventCallbacks = append(s.subscriptionEventCallbacks, cb)
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:48:08 +00:00
|
|
|
func (s *WebSocketService) EmitSubscriptionEvent(e SubscriptionEvent) {
|
2020-10-01 08:07:18 +00:00
|
|
|
for _, cb := range s.subscriptionEventCallbacks {
|
|
|
|
cb(e)
|
|
|
|
}
|
|
|
|
}
|