Documentation ¶
Overview ¶
this 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) GetStreamUrl() string
- func (webSocketChannel *WebSocketChannel) Initialize(log log.T, channelUrl string, channelToken string)
- func (webSocketChannel *WebSocketChannel) Open(log log.T) error
- func (webSocketChannel *WebSocketChannel) SendMessage(log log.T, input []byte, inputType int) error
- func (webSocketChannel *WebSocketChannel) SetChannelToken(channelToken string)
- func (webSocketChannel *WebSocketChannel) SetOnError(onErrorHandler func(error))
- func (webSocketChannel *WebSocketChannel) SetOnMessage(onMessageHandler func([]byte))
- 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(log log.T, channelUrl string, channelToken string) Open(log log.T) error Close(log log.T) error SendMessage(log log.T, input []byte, inputType int) error StartPings(log log.T, pingInterval time.Duration) GetChannelToken() string GetStreamUrl() string SetChannelToken(string) SetOnError(onErrorHandler func(error)) SetOnMessage(onMessageHandler func([]byte)) }
IWebSocketChannel is the interface for DataChannel.
type WebSocketChannel ¶
type WebSocketChannel struct { IWebSocketChannel Url string OnMessage func([]byte) OnError func(error) IsOpen bool Connection *websocket.Conn ChannelToken string // contains filtered or unexported fields }
WebSocketChannel parent class for 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 gets the channel token
func (*WebSocketChannel) GetStreamUrl ¶
func (webSocketChannel *WebSocketChannel) GetStreamUrl() string
GetStreamUrl gets stream url
func (*WebSocketChannel) Initialize ¶
func (webSocketChannel *WebSocketChannel) Initialize(log log.T, channelUrl string, channelToken string)
Initialize initializes websocket channel fields
func (*WebSocketChannel) Open ¶
func (webSocketChannel *WebSocketChannel) Open(log log.T) error
Open upgrades the http connection to a websocket connection.
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(channelToken string)
SetChannelToken sets the channel token
func (*WebSocketChannel) SetOnError ¶
func (webSocketChannel *WebSocketChannel) SetOnError(onErrorHandler func(error))
SetOnError sets OnError field of websocket channel
func (*WebSocketChannel) SetOnMessage ¶
func (webSocketChannel *WebSocketChannel) SetOnMessage(onMessageHandler func([]byte))
SetOnMessage sets OnMessage field of websocket channel
func (*WebSocketChannel) StartPings ¶
func (webSocketChannel *WebSocketChannel) StartPings(log log.T, pingInterval time.Duration)
StartPings starts the pinging process to keep the websocket channel alive.