packet

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartDelimiter  = 0xd1
	EndDelimiter    = 0xd2
	MsgStart        = 0
	MsgSessionStart = 1
	MsgSessionEnd   = 5
	HeaderLength    = 9
)

Variables

View Source
var (
	ErrInvalidStart  = errors.New("read invalid start delimiter")
	ErrInvalidEnd    = errors.New("read invalid end delimiter")
	ErrInvalidHeader = errors.New("invalid header")
	ErrNullSpites    = errors.New("parsed 0 spite")
)

Functions

func Chunked

func Chunked(content []byte, max int) chan []byte

func Count

func Count(content []byte, max int) int

func MarshalMessage

func MarshalMessage(sessionId []byte, msg proto.Message) ([]byte, error)

func ParseHeader

func ParseHeader(header []byte) ([]byte, int, error)

func ParseMessage

func ParseMessage(body []byte) (proto.Message, error)

func ReadHeader

func ReadHeader(conn net.Conn) ([]byte, int, error)

func ReadHeaderWithTimeout

func ReadHeaderWithTimeout(conn net.Conn, timeout time.Duration) ([]byte, int, error)

func ReadMessage

func ReadMessage(conn net.Conn, length int) (proto.Message, error)

func ReadMessageWithTimeout

func ReadMessageWithTimeout(conn net.Conn, length int, timeout time.Duration) (proto.Message, error)

func ReadPacket

func ReadPacket(conn net.Conn) ([]byte, proto.Message, error)

func ReadPacketWithTimeout

func ReadPacketWithTimeout(conn net.Conn, timeout time.Duration) ([]byte, proto.Message, error)

func WritePacket

func WritePacket(conn net.Conn, msg proto.Message, sessionId []byte) error

func WritePacketWithTimeout

func WritePacketWithTimeout(conn net.Conn, msg proto.Message, sessionId []byte, timeout time.Duration) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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