communicator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package communicator implements a base communicator for network connections.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConnectionClosed is returned when the connection is closed.
	ErrConnectionClosed = fmt.Errorf("%w: connection closed", io.EOF)

	// ErrEmptyInput is returned when the input is empty.
	ErrEmptyInput = errors.New("input is empty")
)

Functions

This section is empty.

Types

type IWebSocketChannel

type IWebSocketChannel interface {
	Open() error
	Close() error
	ReadMessage() ([]byte, error)
	SendMessage(input []byte, inputType int) error
	GetChannelToken() string
	GetStreamURL() string
	SetChannelToken(channelToken string)
}

IWebSocketChannel is the interface for DataChannel.

type WebSocketChannel

type WebSocketChannel struct {
	// contains filtered or unexported fields
}

WebSocketChannel parent class for DataChannel.

func NewWebSocketChannel

func NewWebSocketChannel(channelURL string, channelToken string, logger log.T) (*WebSocketChannel, error)

NewWebSocketChannel creates a WebSocketChannel.

func (*WebSocketChannel) Close

func (c *WebSocketChannel) Close() error

Close closes the corresponding connection.

func (*WebSocketChannel) GetChannelToken

func (c *WebSocketChannel) GetChannelToken() string

GetChannelToken gets the channel token.

func (*WebSocketChannel) GetStreamURL

func (c *WebSocketChannel) GetStreamURL() string

GetStreamURL gets stream url.

func (*WebSocketChannel) IsOpen

func (c *WebSocketChannel) IsOpen() bool

IsOpen checks if the channel is open.

func (*WebSocketChannel) Open

func (c *WebSocketChannel) Open() error

Open upgrades the http connection to a websocket connection.

func (*WebSocketChannel) ReadMessage added in v0.2.0

func (c *WebSocketChannel) ReadMessage() ([]byte, error)

ReadMessage reads a message from the websocket connection.

func (*WebSocketChannel) SendMessage

func (c *WebSocketChannel) SendMessage(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 (c *WebSocketChannel) SetChannelToken(channelToken string)

SetChannelToken sets the channel token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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