packet

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeConnReader

func NewFakeConnReader(frames []Frame) *fakeConnReader

func NewFakeConnWriter

func NewFakeConnWriter() *fakeConnWriter

func NewFakeConstReader

func NewFakeConstReader() *fakeConstReader

Types

type Decoder

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

func NewDecoder

func NewDecoder(r FrameReader) *Decoder

func (*Decoder) NextReader

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

type Encoder

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

func NewEncoder

func NewEncoder(w FrameWriter) *Encoder

func (*Encoder) NextWriter

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

type FakeDiscardWriter

type FakeDiscardWriter struct{}

func (*FakeDiscardWriter) NextWriter

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

type Frame

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

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

type Type

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

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

ByteToPacketType converts a byte to PacketType.

func (Type) BinaryByte

func (id Type) BinaryByte() byte

BinaryByte converts a PacketType to byte in binary.

func (Type) String

func (id Type) String() string

func (Type) StringByte

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