Documentation ¶
Index ¶
- Constants
- func NewWsClient(p WebsocketClientProtocol, wsURL string)
- type BaseWebsocketClient
- func (w *BaseWebsocketClient) OnClose(wasClean bool, code int, reason string)
- func (w *BaseWebsocketClient) OnConnect(conn *websocket.Conn, r *http.Response)
- func (w *BaseWebsocketClient) OnConnecting()
- func (w *BaseWebsocketClient) OnOpen()
- func (w *BaseWebsocketClient) OnWsMessage(payload []byte, isBinary bool)
- func (w *BaseWebsocketClient) Send(msg base.MoneysocketMessage) error
- func (w *BaseWebsocketClient) SendBin(msg []byte) (err error)
- func (w *BaseWebsocketClient) SharedSeed() *beacon.SharedSeed
- type WebsocketClientProtocol
Constants ¶
View Source
const UnknownStatusCode = -1
code is setnt to this when code is unknown
Variables ¶
This section is empty.
Functions ¶
func NewWsClient ¶
func NewWsClient(p WebsocketClientProtocol, wsURL string)
TODO make this do things
Types ¶
type BaseWebsocketClient ¶
type BaseWebsocketClient struct { // See: https://git.io/JtPNQ, gorilla websockets do not suppor tconcurrent writers Mux sync.Mutex Conn *websocket.Conn }
base websocket service you can wrap in a struct so you don't need to reimplement empty event listeners. It also provides a canonical way to send messages
func NewBaseWebsocketClient ¶
func NewBaseWebsocketClient() *BaseWebsocketClient
Creates a websocket client with default options
func (*BaseWebsocketClient) OnClose ¶
func (w *BaseWebsocketClient) OnClose(wasClean bool, code int, reason string)
called when a connection is closed
func (*BaseWebsocketClient) OnConnect ¶
func (w *BaseWebsocketClient) OnConnect(conn *websocket.Conn, r *http.Response)
called on connect, sets the connection object
func (*BaseWebsocketClient) OnConnecting ¶
func (w *BaseWebsocketClient) OnConnecting()
called when connection is established
func (*BaseWebsocketClient) OnOpen ¶
func (w *BaseWebsocketClient) OnOpen()
called when the connection is opened
func (*BaseWebsocketClient) OnWsMessage ¶
func (w *BaseWebsocketClient) OnWsMessage(payload []byte, isBinary bool)
called when a ws message is received
func (*BaseWebsocketClient) Send ¶
func (w *BaseWebsocketClient) Send(msg base.MoneysocketMessage) error
send a websocket message
func (*BaseWebsocketClient) SendBin ¶
func (w *BaseWebsocketClient) SendBin(msg []byte) (err error)
send a binary message
func (*BaseWebsocketClient) SharedSeed ¶
func (w *BaseWebsocketClient) SharedSeed() *beacon.SharedSeed
get shared seed
type WebsocketClientProtocol ¶
type WebsocketClientProtocol interface { // calls when a new connection is made OnConnecting() // the client has connected OnConnect(conn *websocket.Conn, r *http.Response) // connection is open OnOpen() // handle incoming messages OnWsMessage(payload []byte, isBinary bool) // called when connection isclosed OnClose(wasClean bool, code int, reason string) // send a message Send(msg base.MoneysocketMessage) error // send a binary-encoded message SendBin(msg []byte) error SharedSeed() *beacon.SharedSeed // contains filtered or unexported methods }
WebsocketClientProtocol class attempts to emulate the twisted socket interface for usabilities sake and calls events on downstream nexuses
Click to show internal directories.
Click to hide internal directories.