socketio

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorEmptyPacket = errors.New("packet length should be at least 1 byte")
	ErrorNullPacket  = errors.New("packet length should be at least 1")
)

Functions

func EncodePacket

func EncodePacket(p Packet) (string, error)

Types

type Client

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

func NewClient

func NewClient(url string, logger *logrus.Logger) *Client

func (*Client) Handle

func (c *Client) Handle(h Handler)

func (*Client) HandleFunc

func (c *Client) HandleFunc(fn func(p *Packet))

func (*Client) HandleMessage

func (c *Client) HandleMessage(msg string) error

HandleMessage handles Event.IO Message.

func (*Client) NextReqID

func (c *Client) NextReqID() int

func (*Client) Open

func (c *Client) Open() error

func (*Client) Send

func (c *Client) Send(data []interface{}) error

func (*Client) SendAck

func (c *Client) SendAck(data []interface{}) ([]interface{}, error)

func (*Client) SendPacket

func (c *Client) SendPacket(p Packet) error

func (*Client) SendPacketAck

func (c *Client) SendPacketAck(p Packet) ([]interface{}, error)

type Handler

type Handler interface {
	HandleMessage(packet *Packet)
}

type HandlerFunc

type HandlerFunc func(packet *Packet)

func (HandlerFunc) HandleMessage

func (f HandlerFunc) HandleMessage(packet *Packet)

type Packet

type Packet struct {
	Type PacketType
	ID   *int
	Data []interface{}
}

func DecodePacket

func DecodePacket(data string) (Packet, error)

func NewAckPacket

func NewAckPacket(p *Packet, data []interface{}) Packet

type PacketType

type PacketType int
const (
	Connect PacketType = iota
	Disconnect
	Event
	Ack
	Error
	BinaryEvent
	BinaryAck
)

func (PacketType) String

func (pt PacketType) String() string

Jump to

Keyboard shortcuts

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