websocket

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func Connect

func Connect(ctx context.Context, config ClientConfig) (*Client, error)

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

func (*Client) Ping

func (c *Client) Ping(data []byte)

func (*Client) SendClose

func (c *Client) SendClose(code ws.StatusCode, reason string)

func (*Client) Write

func (c *Client) Write(opcode ws.OpCode, data []byte)

func (*Client) WriteBinary

func (c *Client) WriteBinary(data []byte)

func (*Client) WriteText

func (c *Client) WriteText(data []byte)

type ClientConfig

type ClientConfig struct {
	URL         string
	DialTimeout time.Duration
	Headers     http.Header
	OnText      func(data []byte) error
	OnBinary    func(data []byte) error
	Logger      *slog.Logger
}

type HandlerFunc

type HandlerFunc func(data []byte) error

func Json

func Json[T any](j func(x T) error) HandlerFunc

Jump to

Keyboard shortcuts

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