xwebsocket

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 7 Imported by: 0

README

xwebsocket

GoDev Build Status Coverage Status Go Report Card Deepsource.io Card

Websocket client, utils, ping/pong handlers, logging

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrChanIsFull = errors.New("chan is full")

Functions

This section is empty.

Types

type Client

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

func (*Client) Disconnect

func (wsc *Client) Disconnect()

Disconnect cancel ctx. y d better cancel parent context in order to disconnect.

func (*Client) OnWSUpgrade

func (wsc *Client) OnWSUpgrade(ctx context.Context, conn *websocket.Conn, rawMsgChan chan *RawMsg)

OnWSUpgrade should be triggered whe websocket upgraded.

func (*Client) RawMsgSend

func (wsc *Client) RawMsgSend(msg *RawMsg)

RawMsgSend send RawMsg.

func (*Client) RawMsgSendNonBlock

func (wsc *Client) RawMsgSendNonBlock(msg *RawMsg)

RawMsgSendNonBlock sends msg and do not block.

func (*Client) ReadWorker

func (wsc *Client) ReadWorker(fnLog log.FnT, traceID string, cb ReaderCb)

ReadWorker handles all reads operations for websocket connection.

prefix => log-prefix.

func (*Client) TextMsgSend

func (wsc *Client) TextMsgSend(text []byte)

TextMsgSend sends text message.

func (*Client) TextMsgSendWithDone

func (wsc *Client) TextMsgSendWithDone(text []byte, done chan error)

TextMsgSendWithDone sends text message with done send chan.

func (*Client) WriteWorker

func (wsc *Client) WriteWorker(fnLog log.FnT, traceID string,

	enablePing bool,
	pingPeriod,
	writeTimeout time.Duration,

	enablePongHandler bool,
	readTimeout time.Duration,
)

WriteWorker handles all writes operations for websocket connection. Some ws endpoints don't support ping/pong. enablePing == false. pingPeriod, writeTimeout are useless. enablePongHandler == false. readTimeout is useless.

type RawMsg

type RawMsg struct {
	// websocket.BinaryMessage
	// websocket.TextMessage
	Type int
	Data []byte
	Done chan error
}

type ReaderCb

type ReaderCb func(t int, raw []byte) error

Jump to

Keyboard shortcuts

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