Documentation ¶
Index ¶
- Constants
- Variables
- func CreateOpenPingPongHandler() http.HandlerFunc
- func CreateTestSocketIOHandler(handler func(c *websocket.Conn)) http.HandlerFunc
- func CreateTestSocketIOServer(mux *http.ServeMux) (*httptest.Server, string)
- func QuickEncode(p Packet) []byte
- type BinaryPacket
- type Conn
- type ConnConfig
- type KeepAliveConn
- func (k *KeepAliveConn) Close() error
- func (k *KeepAliveConn) Connected() bool
- func (k *KeepAliveConn) ID() string
- func (k *KeepAliveConn) KeepAliveContext(ctx context.Context)
- func (k *KeepAliveConn) Opened() <-chan OpenData
- func (k *KeepAliveConn) Read() <-chan Packet
- func (k *KeepAliveConn) SupportsBinary() bool
- func (k *KeepAliveConn) Write() chan<- Packet
- type OpenData
- type Packet
- type PacketConn
- type PacketType
- type RawConn
- type StringPacket
Constants ¶
const ParserProtocol int = 3
ParserProtocol is the version of the Engine.IO parser protocol that this library implements
Variables ¶
var ErrDisconnected = errors.New("Transport disconnected")
ErrDisconnected is returned when the transport is closed
var ErrInvalidType = errors.New("Invalid packet type")
ErrInvalidType is returned when a packet contains an invalid type
var ErrPacketTooShort = errors.New("Packet is too short")
ErrPacketTooShort is returned when a packet does not contain enough bytes to be parsed
Functions ¶
func CreateOpenPingPongHandler ¶
func CreateOpenPingPongHandler() http.HandlerFunc
func CreateTestSocketIOHandler ¶
func CreateTestSocketIOHandler(handler func(c *websocket.Conn)) http.HandlerFunc
func QuickEncode ¶
Types ¶
type BinaryPacket ¶
type BinaryPacket struct { Type PacketType Data []byte }
BinaryPacket represents a engine.io packet with binary (byte) contents
func (*BinaryPacket) Encode ¶
func (p *BinaryPacket) Encode(binary bool) ([]byte, error)
Encode returns the encoded engine.io packet
func (*BinaryPacket) GetData ¶
func (p *BinaryPacket) GetData() []byte
GetData returns the data contained in the packet
func (*BinaryPacket) GetType ¶
func (p *BinaryPacket) GetType() PacketType
GetType returns the engine.io packet type of the packet
type ConnConfig ¶
type KeepAliveConn ¶
KeepAliveConn wraps a Conn and handles the Ping/Pong process
func NewKeepAliveConn ¶
func NewKeepAliveConn(conn PacketConn, readBufferSize int, outgoing chan Packet) *KeepAliveConn
NewKeepAliveConn returns a new instance of KeepAliveConn
func (*KeepAliveConn) Close ¶
func (k *KeepAliveConn) Close() error
Close stops the Ping/Pong process and closes the wrapped Conn
func (*KeepAliveConn) Connected ¶ added in v0.9.5
func (k *KeepAliveConn) Connected() bool
func (*KeepAliveConn) ID ¶
func (k *KeepAliveConn) ID() string
ID returns the ID of the wrapped Conn
func (*KeepAliveConn) KeepAliveContext ¶
func (k *KeepAliveConn) KeepAliveContext(ctx context.Context)
KeepAliveContext starts the Ping/Pong process
func (*KeepAliveConn) Opened ¶
func (k *KeepAliveConn) Opened() <-chan OpenData
func (*KeepAliveConn) Read ¶
func (k *KeepAliveConn) Read() <-chan Packet
func (*KeepAliveConn) SupportsBinary ¶
func (k *KeepAliveConn) SupportsBinary() bool
SupportsBinary returns whether the wrapped Conn supports binary
func (*KeepAliveConn) Write ¶
func (k *KeepAliveConn) Write() chan<- Packet
type Packet ¶
type Packet interface { GetType() PacketType Encode(bool) ([]byte, error) GetData() []byte }
Packet represents a generic engine.io packet
func DecodeBinaryPacket ¶
DecodeBinaryPacket returns a BinaryPacket from the contents of the byte array
func DecodeStringPacket ¶
DecodeStringPacket returns a StringPacket or BinaryPacket from the contents of the string
type PacketConn ¶
type PacketType ¶
type PacketType uint8
PacketType is the type of engine.io the packet being encoded or decoded
const ( // Open is a packet that is sent when a connection is first opened Open PacketType = iota // Close is a packet that is sent when a connection is closed Close // Ping is a packet that is sent to indicated that the connection is still active Ping // Pong is a packet that is sent to indicate that the remote ping was received Pong // Message is a packet that is sent to transfer data Message // Upgrade is a packet that is sent to indicate that an upgrade should occur Upgrade // NoOp is a packet that is sent that should cause no action when received NoOp )
type RawConn ¶
RawConn is a connection to an Engine.IO connection
func DialContext ¶
DialContext creates a RawConn to the Engine.IO server located at address
func (*RawConn) SupportsBinary ¶
SupportsBinary returns true if the underlying connection supports sending raw binary data (bytes), false otherwise
type StringPacket ¶
type StringPacket struct { Type PacketType Data *string }
StringPacket represents an engine.io packet with UTF-8 string contents
func (*StringPacket) Encode ¶
func (p *StringPacket) Encode(binary bool) ([]byte, error)
Encode returns the encoded engine.io packet
func (*StringPacket) GetData ¶
func (p *StringPacket) GetData() []byte
GetData returns the data contained in the packet
func (*StringPacket) GetType ¶
func (p *StringPacket) GetType() PacketType
GetType returns the engine.io packet type of the packet