engineio_v4_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: 14 Imported by: 2 modules, 1 package

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("client is closed")

ErrClientClosed is returned when Connect is called after Close.

View Source
var ErrConnectAborted = errors.New("engine.io: connect aborted: client closed")
View Source
var ErrConnectAlreadyStarted = errors.New("engine.io: Connect has already been called")

ErrConnectAlreadyStarted is returned after the client's one public Connect call has started. Create a new client to begin another manual session.

View Source
var ErrPingTimeout = errors.New("engine.io ping timeout")

ErrPingTimeout reports a peer that stopped sending Engine.IO heartbeats.

Functions

This section is empty.

Types

type BinaryTransport added in v0.2.0

type BinaryTransport interface {
	// SendBinary delivers a raw binary attachment over the transport. Over
	// websocket this is a binary frame; over HTTP long-polling it is encoded
	// as a base64 "b"-prefixed record by the transport.
	SendBinary(message []byte) error
}

BinaryTransport is an optional capability of a transport that can write attachment frames in addition to its regular text packet format.

type Client

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

func NewClient

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

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

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

func (*Client) On

func (c *Client) On(event string, handler func([]byte))

func (*Client) Send

func (c *Client) Send(message []byte) error

func (*Client) SendBinary added in v0.2.0

func (c *Client) SendBinary(message []byte) error

func (*Client) SupportsBinary added in v0.2.0

func (c *Client) SupportsBinary() bool

SupportsBinary reports whether the current transport can send binary attachments. Wrappers can use it before writing a multi-frame packet header.

type EngineClientOption

type EngineClientOption func(*Client) error

func WithConnectTimeout added in v0.2.0

func WithConnectTimeout(timeout time.Duration) EngineClientOption

func WithDebugPayload added in v0.2.0

func WithDebugPayload(enabled bool) EngineClientOption

WithDebugPayload enables logging of raw packet payloads at debug level. It is disabled by default so production logs do not leak message contents.

func WithLogger

func WithLogger(logger Logger) EngineClientOption

func WithOnReconnect added in v0.2.0

func WithOnReconnect(handler func()) EngineClientOption

WithOnReconnect registers a hook fired after the client successfully re-establishes the connection. Equivalent to On("reconnect", ...).

func WithOnReconnectFailed added in v0.2.0

func WithOnReconnectFailed(handler func()) EngineClientOption

WithOnReconnectFailed registers a hook fired when all reconnect attempts are exhausted (the client is then closed). Equivalent to On("reconnect_failed", ...).

func WithOnReconnecting added in v0.2.0

func WithOnReconnecting(handler func()) EngineClientOption

WithOnReconnecting registers a hook fired when an unexpected drop is detected and the client begins its reconnect attempts. Equivalent to On("reconnecting", ...).

func WithParser

func WithParser(parser Parser) EngineClientOption

func WithRawURL

func WithRawURL(urlRaw string) EngineClientOption

func WithReconnect added in v0.2.0

func WithReconnect(enabled bool) EngineClientOption

WithReconnect enables or disables automatic reconnection with exponential backoff. It is enabled by default; passing false makes the client stop on the first unexpected transport drop, exactly as it behaved before reconnection was added.

func WithReconnectAttempts

func WithReconnectAttempts(attempts int) EngineClientOption

func WithReconnectWait

func WithReconnectWait(wait time.Duration) EngineClientOption

func WithSupportedTransports

func WithSupportedTransports(transports []Transport) EngineClientOption

func WithTransport

func WithTransport(transport Transport) EngineClientOption

func WithURL

func WithURL(input *url.URL) EngineClientOption

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 {
	Parse([]byte) (
		*engineio_v4.Message,
		error,
	)
	Serialize(*engineio_v4.Message) (
		[]byte,
		error,
	)
}

type Transport

type Transport interface {
	Transport() engineio_v4.EngineIOTransport
	Run(
		ctx context.Context,
		url *url.URL,
		sid string,
		messagesChan chan<- engineio_v4.Frame,
		onClose chan<- error,
	) error
	SetHandshake(handshake *engineio_v4.HandshakeResponse)
	RequestHandshake() error
	Stop() error
	SendMessage(message []byte) error
}

Directories

Path Synopsis
Package mock_engineio_v4_client is a generated GoMock package.
Package mock_engineio_v4_client is a generated GoMock package.
transport
polling/mocks
Package mock_engineio_v4_client_transport is a generated GoMock package.
Package mock_engineio_v4_client_transport is a generated GoMock package.
websocket/mocks
Package mock_engineio_v4_client_transport is a generated GoMock package.
Package mock_engineio_v4_client_transport is a generated GoMock package.

Jump to

Keyboard shortcuts

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