Documentation
¶
Overview ¶
Package engineio implements the Engine.IO v4 protocol codec — the transport framing layer that Socket.IO is built on. It encodes and decodes the small set of Engine.IO packets and the polling "payload" that batches several packets into a single HTTP body.
Engine.IO packet wire format (string): a single-digit type prefix followed by the packet data, e.g. "4hello" is a MESSAGE packet carrying "hello".
Index ¶
Constants ¶
const Protocol = 4
Protocol is the Engine.IO protocol revision implemented here.
Variables ¶
var ErrEmptyPacket = errors.New("engineio: empty packet")
ErrEmptyPacket is returned when decoding an empty packet string.
Functions ¶
func EncodePayload ¶
EncodePayload joins packets into a single polling payload, separated by the record separator.
Types ¶
type Packet ¶
type Packet struct {
// Type is the Engine.IO packet type (Open, Message, Ping, ...).
Type PacketType
// Data is the textual payload for string packets.
Data string
// Binary holds raw bytes for binary packets; when non-nil the packet is
// encoded with a "b" prefix + base64 in polling payloads.
Binary []byte
}
Packet is a single Engine.IO packet.
func DecodePayload ¶
DecodePayload splits a polling payload into its constituent packets.
func NewMessage ¶
NewMessage builds a MESSAGE packet with string data.
type PacketType ¶
type PacketType byte
PacketType identifies an Engine.IO packet.
const ( // Open is sent by the server on connection with the handshake data. Open PacketType = iota // Close requests the transport be closed. Close // Ping is part of the heartbeat (server -> client in EIO4). Ping // Pong answers a Ping. Pong // Message carries an application payload (a Socket.IO packet). Message // Upgrade signals a transport upgrade (polling -> websocket). Upgrade // Noop does nothing; used to cleanly terminate a polling request. Noop )
func (PacketType) String ¶
func (t PacketType) String() string
String returns the lowercase Engine.IO name of the packet type (e.g. "message", "ping"), or "unknown" for an unrecognized value.