packet

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: BSD-3-Clause Imports: 4 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeConnReader added in v1.5.0

func NewFakeConnReader(frames []Frame) *fakeConnReader

func NewFakeConnWriter added in v1.5.0

func NewFakeConnWriter() *fakeConnWriter

func NewFakeConstReader added in v1.5.0

func NewFakeConstReader() *fakeConstReader

Types

type Decoder added in v1.5.0

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

func NewDecoder

func NewDecoder(r FrameReader) *Decoder

func (*Decoder) NextReader added in v1.5.0

func (e *Decoder) NextReader() (frame.Type, Type, io.ReadCloser, error)

type Encoder added in v1.5.0

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

func NewEncoder

func NewEncoder(w FrameWriter) *Encoder

func (*Encoder) NextWriter added in v1.5.0

func (e *Encoder) NextWriter(ft frame.Type, pt Type) (io.WriteCloser, error)

type FakeDiscardWriter added in v1.5.0

type FakeDiscardWriter struct{}

func (*FakeDiscardWriter) NextWriter added in v1.5.0

func (w *FakeDiscardWriter) NextWriter(fType frame.Type) (io.WriteCloser, error)

type Frame added in v1.5.0

type Frame struct {
	FType frame.Type
	Data  []byte
}

type FrameReader

type FrameReader interface {
	NextReader() (frame.Type, io.ReadCloser, error)
}

FrameReader is the reader which supports framing.

type FrameWriter

type FrameWriter interface {
	NextWriter(typ frame.Type) (io.WriteCloser, error)
}

FrameWriter is the writer which supports framing.

type Packet added in v1.5.0

type Packet struct {
	FType frame.Type
	PType Type
	Data  []byte
}

type Type added in v1.5.0

type Type int

Type is the type of packet

const (
	// OPEN is sent from the server when a new transport is opened (recheck).
	OPEN Type = iota
	// CLOSE is request the close of this transport but does not shutdown the
	// connection itself.
	CLOSE
	// PING is sent by the client. Server should answer with a pong packet
	// containing the same data.
	PING
	// PONG is sent by the server to respond to ping packets.
	PONG
	// MESSAGE is actual message, client and server should call their callbacks
	// with the data.
	MESSAGE
	// UPGRADE is sent before engine.io switches a transport to test if server
	// and client can communicate over this transport. If this test succeed,
	// the client sends an upgrade packets which requests the server to flush
	// its cache on the old transport and switch to the new transport.
	UPGRADE
	// NOOP is a noop packet. Used primarily to force a poll cycle when an
	// incoming websocket connection is received.
	NOOP
)

func ByteToPacketType added in v1.5.0

func ByteToPacketType(b byte, typ frame.Type) Type

ByteToPacketType converts a byte to PacketType.

func (Type) BinaryByte added in v1.5.0

func (id Type) BinaryByte() byte

BinaryByte converts a PacketType to byte in binary.

func (Type) String added in v1.5.0

func (id Type) String() string

func (Type) StringByte added in v1.5.0

func (id Type) StringByte() byte

StringByte converts a PacketType to byte in string.

Jump to

Keyboard shortcuts

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