socket

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedType = errors.New("Unexpected type")

ErrUnexpectedType is returned when the decoder is trying to replace placeholders with []byte and encounters an unexpected type

View Source
var ErrWaitingForMorePackets = errors.New("Waiting for more packets")

ErrWaitingForMorePackets is returned when the Decoder has not yet received enough BinaryPackets to fully decode a binary message

Functions

func HasBinary

func HasBinary(data interface{}) bool

HasBinary returns true if the data contains []byte or fixed-length byte arrays, false otherwise

func IsRootNamespace

func IsRootNamespace(namespace string) bool

IsRootNamespace returns true if the namespace is / or "", false otherwise

Types

type BinaryDecoder

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

BinaryDecoder reconstructs BinaryEvents and BinaryAcks from multiple EnginePackets

func (*BinaryDecoder) Decode

func (d *BinaryDecoder) Decode(packet engine.Packet) (Packet, error)

Decode returns either a Message, or ErrWaitingForMorePackets if additional Packets are required to fully reconstruct a BinaryEvent or BinaryAck

func (*BinaryDecoder) Reset

func (d *BinaryDecoder) Reset()

Reset clears the current state of the BinaryDecoder

type BinaryPlaceholder

type BinaryPlaceholder struct {
	Placeholder bool `json:"_placeholder"`
	Number      int  `json:"num"`
}

BinaryPlaceholder represents the position of a particular binary attachement in a string-encoded packet

type Packet

type Packet struct {
	Type            PacketType
	ID              *int64
	Namespace       string
	AttachmentCount int
	Data            interface{}
}

Packet is a Socket.IO packet

func (*Packet) Encode

func (p *Packet) Encode(supportsBinary bool) ([][]byte, error)

Encode encodes a Packet into an array of []byte buffers

func (Packet) String

func (p Packet) String() string

type PacketType

type PacketType int

PacketType is the Socket.IO-defined type of this packet

const (
	// Connect represents a packet that is sent when the remote connection is
	// initially established
	Connect PacketType = iota
	// Disconnect represents a packet that is sent when the remote connection is broken
	// either intentionally or unintentionally
	Disconnect
	// Event represents a packet that contains event information. Packets of this type
	// may be sent by either side at any time after the connection is established
	Event
	// Ack represents a packet that contains a payload acknowledging receipt of a previously
	// sent Event
	Ack
	// Error represents a packet that contains error information
	Error
	// BinaryEvent represents a packet that contains event information. Packets of this type
	// may be sent by either side at any time after the connection is established
	BinaryEvent
	// BinaryAck represents a packet that contains a payload acknowledging receipt of a previously
	// sent Event
	BinaryAck
)

Jump to

Keyboard shortcuts

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