stream

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConnection connection is not valid
	ErrInvalidConnection = errors.New("connection is not valid")
)

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Host            string `validate:"required"`
	Channel         string `validate:"required"`
	AccessKey       string `validate:"required"`
	RedirectService bool
	SkipServerAuth  bool
}

Credentials is the input needed to login to the Symbl.ai platform

type WebSocketClient

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

WebSocketClient return websocket client connection

func NewWebSocketClient

func NewWebSocketClient(ctx context.Context, creds Credentials, callback WebSocketMessageCallback) (*WebSocketClient, error)

NewWebSocketClient create new websocket connection

func (*WebSocketClient) AttemptReconnect

func (conn *WebSocketClient) AttemptReconnect(retries int64) *websocket.Conn

AttemptReconnect does exactly that...

func (*WebSocketClient) Connect

func (conn *WebSocketClient) Connect() *websocket.Conn

Connect performs a websocket connection with "defaultConnectRetry" number of retries.

func (*WebSocketClient) ConnectWithRetry

func (conn *WebSocketClient) ConnectWithRetry(retries int64) *websocket.Conn

ConnectWithRetry is a function to explicitly do a reconnect

func (*WebSocketClient) Stop

func (conn *WebSocketClient) Stop()

Stop will send close message and shutdown websocket connection

func (*WebSocketClient) Write

func (conn *WebSocketClient) Write(p []byte) (int, error)

Write performs the lower level websocket write operation

func (*WebSocketClient) WriteBinary

func (conn *WebSocketClient) WriteBinary(byData []byte) error

WriteBinary writes a Go struct to the websocket server

func (*WebSocketClient) WriteJSON

func (conn *WebSocketClient) WriteJSON(payload interface{}) error

WriteJSON writes a JSON payload to the websocket server

type WebSocketMessageCallback

type WebSocketMessageCallback interface {
	Message(byMsg []byte) error
}

WebSocketMessageCallback is a callback used to write a message on websocket without exposing the entire struct to the user

Jump to

Keyboard shortcuts

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