protocol

package
v0.0.0-...-299b620 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeOpen        = iota // message with connection options
	MessageTypeClose              // close connection and destroy all handle routines
	MessageTypePing               // ping request message
	MessageTypePong               // pong response message
	MessageTypeEmpty              // empty message
	MessageTypeEmit               // emit request, no response
	MessageTypeAckRequest         // emit request, wait for response (ack)
	MessageTypeAckResponse        // ack response
	MessageTypeUpgrade            // upgrade message
	MessageTypeBlank              // blank message
)
View Source
const (
	MessageOpen      = "0"
	MessageClose     = "1"
	MessagePing      = "2"
	MessagePingProbe = "2probe"
	MessagePongProbe = "3probe"
	MessagePong      = "3"

	MessageEmpty = "40"

	MessageUpgrade = "5"
	MessageBlank   = "6"
	MessageStub    = "stub"
)

Variables

View Source
var (
	ErrorWrongMessageType = errors.New("wrong message type")
	ErrorWrongPacket      = errors.New("wrong packet")
)

Functions

func Encode

func Encode(m *Message) (string, error)

Encode a socket.io message m to the protocol format

func MustEncode

func MustEncode(m *Message) string

MustEncode the message m acts like Encode but panics on error

Types

type Message

type Message struct {
	Type      int
	AckID     int
	EventName string
	Args      string
	Source    string
}

Message represents socket.io message

func Decode

func Decode(data string) (*Message, error)

Decode the given data string into a Message

Jump to

Keyboard shortcuts

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