bbgo/pkg/net/websocketbase/websocketclientbase_callbacks.go

48 lines
1.1 KiB
Go

// Code generated by "callbackgen -type WebsocketClientBase"; DO NOT EDIT.
package websocketbase
import (
"github.com/gorilla/websocket"
)
func (s *WebsocketClientBase) OnConnected(cb func(conn *websocket.Conn)) {
s.connectedCallbacks = append(s.connectedCallbacks, cb)
}
func (s *WebsocketClientBase) EmitConnected(conn *websocket.Conn) {
for _, cb := range s.connectedCallbacks {
cb(conn)
}
}
func (s *WebsocketClientBase) OnDisconnected(cb func(conn *websocket.Conn)) {
s.disconnectedCallbacks = append(s.disconnectedCallbacks, cb)
}
func (s *WebsocketClientBase) EmitDisconnected(conn *websocket.Conn) {
for _, cb := range s.disconnectedCallbacks {
cb(conn)
}
}
func (s *WebsocketClientBase) OnMessage(cb func(message []byte)) {
s.messageCallbacks = append(s.messageCallbacks, cb)
}
func (s *WebsocketClientBase) EmitMessage(message []byte) {
for _, cb := range s.messageCallbacks {
cb(message)
}
}
func (s *WebsocketClientBase) OnError(cb func(err error)) {
s.errorCallbacks = append(s.errorCallbacks, cb)
}
func (s *WebsocketClientBase) EmitError(err error) {
for _, cb := range s.errorCallbacks {
cb(err)
}
}