Documentation
¶
Index ¶
- Variables
- type BinaryTransport
- type Client
- type EngineClientOption
- func WithConnectTimeout(timeout time.Duration) EngineClientOption
- func WithDebugPayload(enabled bool) EngineClientOption
- func WithLogger(logger Logger) EngineClientOption
- func WithOnReconnect(handler func()) EngineClientOption
- func WithOnReconnectFailed(handler func()) EngineClientOption
- func WithOnReconnecting(handler func()) EngineClientOption
- func WithParser(parser Parser) EngineClientOption
- func WithRawURL(urlRaw string) EngineClientOption
- func WithReconnect(enabled bool) EngineClientOption
- func WithReconnectAttempts(attempts int) EngineClientOption
- func WithReconnectWait(wait time.Duration) EngineClientOption
- func WithSupportedTransports(transports []Transport) EngineClientOption
- func WithTransport(transport Transport) EngineClientOption
- func WithURL(input *url.URL) EngineClientOption
- type Logger
- type Parser
- type Transport
Constants ¶
This section is empty.
Variables ¶
var ErrClientClosed = errors.New("client is closed")
ErrClientClosed is returned when Connect is called after Close.
var ErrConnectAborted = errors.New("engine.io: connect aborted: client closed")
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.
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) SendBinary ¶ added in v0.2.0
func (*Client) SupportsBinary ¶ added in v0.2.0
SupportsBinary reports whether the current transport can send binary attachments. Wrappers can use it before writing a multi-frame packet header.
type EngineClientOption ¶
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. |