socketio

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Overview

Package socketio provides a very-incomplete client implementation of the socket.io protocol using websockets.

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
}

Type Client reperesents a connection to a socket.io server.

func New

func New(url string, secure bool, dialer websocket.Dialer) (*Client, error)

Function New creates a new Client object.

func (*Client) Disconnect

func (cl *Client) Disconnect()

Method Disconnect closes the connection.

func (*Client) Emit

func (cl *Client) Emit(event string, data ...interface{}) error

Method Emit sends a message.

func (*Client) Listen

func (cl *Client) Listen() error

Method Listen runs the event loop.

func (*Client) On

func (cl *Client) On(event string, handler func(data ...interface{}))

Method On registers an event handler. Each event can only have one handler.

func (*Client) Ping

func (cl *Client) Ping() error

Method Ping pings the server. Most code shouldn't need to run this; it will automatically be handled by Listen.

If you are writing your own event loop, Ping should be run about once every 25 seconds.

func (*Client) Read

func (cl *Client) Read() (Message, error)

Method Read reads the next message. Most code should not have to use this; it is automatically handled by Listen.

type ConnectMessage

type ConnectMessage struct{}

Type ConnectMessage represents a connection message. It is returned by Read.

type DisconnectMessage

type DisconnectMessage struct{}

Type DisconnectMessage represents a disconnection message. It is returned by Read.

type ErrorMessage

type ErrorMessage struct{}

Type ErrorMessage represents an error message. It is returned by Read.

type EventMessage

type EventMessage struct {
	Event string
	Data  []interface{}
}

Type EventMessage represents an event message. It is returned by Read.

type Message

type Message interface{}

Type Message represents a socketio message. It is returned by Read.

type PongMessage

type PongMessage struct{}

Type PongMessage represents a pong message. It is returned by Read.

Jump to

Keyboard shortcuts

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