communicator

package
v0.0.0-...-955c50f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 3

Documentation

Overview

communicator 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(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) Open

func (webSocketChannel *WebSocketChannel) Open(log log.T, dialer *websocket.Dialer) 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(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.

Jump to

Keyboard shortcuts

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