sharedstruct

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteLenOfCSPacketBody

func ByteLenOfCSPacketBody(header []byte) int

func ByteLenOfCSPacketHeader

func ByteLenOfCSPacketHeader() int

func ByteLenOfSSPacketHeader

func ByteLenOfSSPacketHeader() int

Types

type CSPacket

type CSPacket struct {
	Header CSPacketHeader
	Body   []byte
}

type CSPacketHeader

type CSPacketHeader struct {
	Version  uint16
	PassCode uint16
	Seq      uint32

	Uid uint64

	AppVersion uint32
	Cmd        uint32

	BodyLen uint32
}

注意这里的排列是考虑了内存对齐的情况,调整时请注意。

func (*CSPacketHeader) From

func (h *CSPacketHeader) From(b []byte)

func (*CSPacketHeader) To

func (h *CSPacketHeader) To(b []byte)

func (*CSPacketHeader) ToBytes

func (h *CSPacketHeader) ToBytes() []byte

type SSPacket

type SSPacket struct {
	Header SSPacketHeader
	Body   []byte
}

func (*SSPacket) SendToChan

func (h *SSPacket) SendToChan(ch chan *SSPacket, timeout time.Duration) bool

type SSPacketHeader

type SSPacketHeader struct {
	SrcBusID uint32
	DstBusID uint32

	SrcTransID uint32
	DstTransID uint32

	Uid uint64

	Cmd  uint32
	Zone uint32

	Ip   uint32
	Flag uint32

	BodyLen uint32
	CmdSeq  uint16 // Request时+1,Response时不变。用以标识收到的Response是对应哪个发出的Request
}

经过测试,结构体是以8字节为单位对齐的,要注意一下

func (*SSPacketHeader) From

func (h *SSPacketHeader) From(b []byte) error

func (*SSPacketHeader) To

func (h *SSPacketHeader) To(b []byte) error

func (*SSPacketHeader) ToBytes

func (h *SSPacketHeader) ToBytes() []byte

Jump to

Keyboard shortcuts

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