socketio_v5_client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 11 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientClosed = errors.New("socket.io: client is closed")

ErrClientClosed is returned when Connect is called after Close.

View Source
var ErrConnectAlreadyStarted = errors.New("socket.io: Connect has already been called")

ErrConnectAlreadyStarted is returned after the client's one public Connect call has started. Automatic reconnection continues within that session.

Functions

This section is empty.

Types

type BinaryEngineIOClient added in v0.2.0

type BinaryEngineIOClient interface {
	// SendBinary delivers a raw binary attachment frame (the buffers that follow
	// a binary event/ack header).
	SendBinary(message []byte) error
}

BinaryEngineIOClient is implemented by transports that can send attachment frames. It is optional so existing EngineIOClient implementations remain valid.

type BinaryParser added in v0.2.0

type BinaryParser interface {
	// HasBinary reports whether an event carries []byte payloads that must be
	// sent as a binary packet (PacketBinaryEvent/PacketBinaryAck).
	HasBinary(event *socketio_v5.Event) bool
	// SerializeBinary encodes an event with binary payloads into a header packet
	// plus the ordered binary attachments that follow it on the wire.
	SerializeBinary(*socketio_v5.Message) (header []byte, attachments [][]byte, err error)
	// ReconstructBinary substitutes collected binary attachments back into the
	// placeholders of a parsed binary packet, exposing them as []byte.
	ReconstructBinary(msg *socketio_v5.Message, attachments [][]byte) error
}

BinaryParser is an optional capability of parsers that use Socket.IO's separate binary attachment frames. Existing custom parsers keep control of their own wire format through Parser.Serialize.

type Client

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

func NewClient

func NewClient(options ...ClientOption) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, callbacks ...func(arg interface{})) error

func (*Client) Emit

func (c *Client) Emit(event interface{}, args ...interface{}) error

func (*Client) On

func (c *Client) On(event string, handler interface{})

func (*Client) OnAny added in v0.1.1

func (c *Client) OnAny(handler func(string, []interface{}))

func (*Client) SetHandshakeData

func (c *Client) SetHandshakeData(data map[string]interface{})

SetHandshakeData stores a shallow copy of the provided map as the handshake payload. Top-level keys are detached from the caller's map, but nested maps/slices are still shared. Callers must not mutate nested values after calling SetHandshakeData, or supply only flat/JSON-primitive values.

type ClientOption

type ClientOption func(*InitClient) error

func WithConnectTimeout added in v0.2.0

func WithConnectTimeout(timeout time.Duration) ClientOption

WithConnectTimeout limits the duration of the connection phase (transport dial and engine.io handshake) without limiting the session lifetime: with this option set, Connect() fails fast with context.DeadlineExceeded when the server is unreachable, while the context passed to Connect() still controls how long an established session lives.

The option configures the engine.io client built internally by NewClient, so it can't be combined with WithEngineIOClient — pass engineio_v4_client.WithConnectTimeout to your own engine.io client instead.

func WithDebugPayload added in v0.2.0

func WithDebugPayload(enabled bool) ClientOption

WithDebugPayload enables logging of raw payloads at debug level across the client and the default transports it builds. Disabled by default so production logs do not leak message contents (tokens, PII).

func WithDefaultNamespace

func WithDefaultNamespace(ns string) ClientOption

func WithEngineIOClient

func WithEngineIOClient(engineIOClient EngineIOClient) ClientOption

func WithLogger

func WithLogger(logger Logger) ClientOption

func WithMaxBinarySize added in v0.2.0

func WithMaxBinarySize(size int) ClientOption

WithMaxBinarySize sets the maximum aggregate attachment bytes retained for a single inbound binary event or acknowledgement. The default is 64 MiB.

func WithParser

func WithParser(parser Parser) ClientOption

func WithRawURL

func WithRawURL(rawUrl string) ClientOption

func WithTimer

func WithTimer(timer Timer) ClientOption

func WithURL

func WithURL(url *url.URL) ClientOption

type EngineIOClient

type EngineIOClient interface {
	Connect(ctx context.Context) error
	Send(message []byte) error
	On(event string, handler func([]byte))
	Close() error
}

EngineIOClient представляет интерфейс для клиента Engine.IO

type InitClient

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

type Logger

type Logger interface {
	Debugf(format string, v ...any)
	Infof(format string, v ...any)
	Warnf(format string, v ...any)
	Errorf(format string, v ...any)
}

Logger представляет интерфейс для логирования

type Parser

type Parser interface {
	WrapCallback(callback interface{}) func(in []interface{})
	Parse([]byte) (*socketio_v5.Message, error)
	Serialize(*socketio_v5.Message) ([]byte, error)
}

type Timer

type Timer interface {
	After(d time.Duration) <-chan time.Time
}

Timer представляет интерфейс для работы с таймерами

Directories

Path Synopsis
Package mock_socketio_v5_client is a generated GoMock package.
Package mock_socketio_v5_client is a generated GoMock package.

Jump to

Keyboard shortcuts

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