socketio

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConnectionTimeout is the default connection timeout
	ConnectionTimeout = 5 * time.Second
	// ReplyTimeout is the default timeout of reply messages
	ReplyTimeout = 5 * time.Second
	// DefaultPingInterval is the default keepalive ping interval
	DefaultPingInterval = 20 * time.Second

	// InitialReconnectInterval is the initial (minimal) reconnect interval
	InitialReconnectInterval = time.Second
	// MaxReconnectInterval is the maximum reconnect interval
	MaxReconnectInterval = time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

Connection is the single connection to SocketIO server.

func Open

func Open(url string, options ...Option) *Connection

Open creates a new connection to SocketIO server

func (*Connection) Close

func (c *Connection) Close()

Close closes the connection and stops the reconnect cycle.

func (*Connection) Connected

func (c *Connection) Connected() <-chan struct{}

Connected returns the channel of 'connected' events.

func (*Connection) Messages

func (c *Connection) Messages() <-chan IncomingMessage

Messages returns the channel of incoming messages.

func (*Connection) Send

func (c *Connection) Send(command string, payload interface{}) ([]byte, error)

Send sending message to the server and waiting for the response.

type IncomingMessage

type IncomingMessage struct {
	Type    string
	Payload json.RawMessage
}

IncomingMessage represents an incoming message from SocketIO server

func (*IncomingMessage) UnmarshalJSON

func (m *IncomingMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for IncomingMessage.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option allows to configure Connection on create.

func WithLogger

func WithLogger(log debug.Logger) Option

WithLogger allows to configure log of the connection.

type Options

type Options []Option

Options is a list of Option. It satisfies the Option interface itself.

Jump to

Keyboard shortcuts

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