parsing

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHeader

func ParseHeader(rawHead []byte, headerPtr any) (int32, error)

ParseHeader parses raw header bytes into a user-defined protobuf struct. It unmarshals the header and extracts the Msgid field (case-insensitive, supports underscores and dashes).

func WritePacket added in v1.0.16

func WritePacket(ctx context.Context, conn net.Conn, header proto.Message, body proto.Message) error

WritePacket marshals and writes a packet with the given header and body to the provided connection. The packet layout is: [headLen:1][bodyLen:2][headBytes][bodyBytes]. It injects the given msgID into the header's Msgid field if available. It enforces max header (255 bytes) and body (65535 bytes) size constraints.

Types

type PacketEnvelope

type PacketEnvelope struct {
	HeadLen uint8
	BodyLen uint16
	RawHead []byte
	RawBody []byte
}

func ParseEnvelope

func ParseEnvelope(conn net.Conn) (*PacketEnvelope, error)

ParseEnvelope extracts the raw header and body using the first three bytes.

Jump to

Keyboard shortcuts

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