Documentation
¶
Overview ¶
Package client is a Go Socket.IO client. It connects to a Socket.IO server (this one or the Node reference server) over the WebSocket transport and provides the familiar On/Emit/EmitWithAck API.
c, err := client.Dial("http://localhost:3000")
c.On("news", func(args []any) []any { fmt.Println(args); return nil })
c.Emit("hello", "world")
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
}
Client is a connected Socket.IO client.
func Dial ¶
Dial connects to a Socket.IO server at rawURL (http:// or ws://) and returns once the Socket.IO CONNECT handshake completes.
func (*Client) EmitWithAck ¶
EmitWithAck sends an event and waits for the server's acknowledgement, up to timeout.
type Handler ¶
Handler handles an inbound event. Returning a non-nil slice acknowledges an event the server sent with an ack id.
type Options ¶
type Options struct {
// Namespace to connect to (default "/").
Namespace string
// Auth is an optional payload sent with the CONNECT packet.
Auth any
// DialTimeout bounds the connection handshake (default 10s).
DialTimeout time.Duration
// Reconnection enables automatic reconnection after an unexpected
// disconnect.
Reconnection bool
// ReconnectionAttempts bounds reconnection tries (0 = unlimited).
ReconnectionAttempts int
// ReconnectionDelay is the initial backoff between attempts (default 1s,
// doubling up to 5s).
ReconnectionDelay time.Duration
}
Options configures Dial.
Click to show internal directories.
Click to hide internal directories.