Documentation ¶
Overview ¶
communicator package implement base communicator for network connections.
Index ¶
- type IWebSocketChannel
- type WebSocketChannel
- func (webSocketChannel *WebSocketChannel) Close(log log.T) error
- func (webSocketChannel *WebSocketChannel) GetChannelToken() string
- func (webSocketChannel *WebSocketChannel) Initialize(context context.T, channelId string, channelType string, channelRole string, ...) error
- func (webSocketChannel *WebSocketChannel) Open(log log.T, dialer *websocket.Dialer) error
- func (webSocketChannel *WebSocketChannel) SendMessage(log log.T, input []byte, inputType int) error
- func (webSocketChannel *WebSocketChannel) SetChannelToken(token string)
- func (webSocketChannel *WebSocketChannel) SetSubProtocol(subProtocol string)
- func (webSocketChannel *WebSocketChannel) SetUrl(url string)
- func (webSocketChannel *WebSocketChannel) StartPings(log log.T, pingInterval time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IWebSocketChannel ¶
type IWebSocketChannel interface { Initialize(context context.T, channelId string, channelType string, channelRole string, channelToken string, region string, signer *v4.Signer, onMessageHandler func([]byte), onErrorHandler func(error)) error Open(log log.T, dialer *websocket.Dialer) error Close(log log.T) error GetChannelToken() string SetChannelToken(token string) StartPings(log log.T, pingInterval time.Duration) SendMessage(log log.T, input []byte, inputType int) error SetUrl(url string) SetSubProtocol(subProtocol string) }
IWebSocketChannel is the interface for ControlChannel and DataChannel.
type WebSocketChannel ¶
type WebSocketChannel struct { OnMessage func([]byte) OnError func(error) Context context.T ChannelToken string Connection *websocket.Conn Url string SubProtocol string Signer *v4.Signer Region string IsOpen bool // contains filtered or unexported fields }
WebSocketChannel parent class for ControlChannel and DataChannel.
func (*WebSocketChannel) Close ¶
func (webSocketChannel *WebSocketChannel) Close(log log.T) error
Close closes the corresponding connection.
func (*WebSocketChannel) GetChannelToken ¶
func (webSocketChannel *WebSocketChannel) GetChannelToken() string
GetChannelToken returns channelToken field.
func (*WebSocketChannel) Initialize ¶
func (webSocketChannel *WebSocketChannel) Initialize(context context.T, channelId string, channelType string, channelRole string, channelToken string, region string, signer *v4.Signer, onMessageHandler func([]byte), onErrorHandler func(error)) error
Initialize a WebSocketChannel object.
func (*WebSocketChannel) SendMessage ¶
SendMessage sends a byte message through the websocket connection. Examples of message type are websocket.TextMessage or websocket.Binary
func (*WebSocketChannel) SetChannelToken ¶
func (webSocketChannel *WebSocketChannel) SetChannelToken(token string)
SetChannelToken updates the token field.
func (*WebSocketChannel) SetSubProtocol ¶
func (webSocketChannel *WebSocketChannel) SetSubProtocol(subProtocol string)
SetSubProtocol sets the subprotocol for the WebSocketChannel.
func (*WebSocketChannel) SetUrl ¶
func (webSocketChannel *WebSocketChannel) SetUrl(url string)
SetUrl sets the url for the WebSocketChannel.
func (*WebSocketChannel) StartPings ¶
func (webSocketChannel *WebSocketChannel) StartPings(log log.T, pingInterval time.Duration)
StartPings starts the pinging process to keep the websocket channel alive.
Directories ¶
Path | Synopsis |
---|---|
Code generated by mockery v1.0.0
|
Code generated by mockery v1.0.0 |
Package websocketutil contains methods for interacting with websocket connections.
|
Package websocketutil contains methods for interacting with websocket connections. |