communicator

package
v0.0.0-...-7b544e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

this package implement base communicator for network connections.

Index

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

func (webSocketChannel *WebSocketChannel) SendMessage(log log.T, input []byte, inputType int) error

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.

Directories

Path Synopsis
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL