cstruct

package
v0.0.0-...-8c018af Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_TYPE_NONE uint8 = 0    // 默认的一般消息类型
	MSG_TYPE_RPC  uint8 = 0x01 // rpc

)

Variables

View Source
var DefaultRecvMsg = &RecvMsg{0, 0, nil, MSG_TYPE_NONE}

Functions

func FlagGet

func FlagGet(value uint8, flag uint8) bool

func FlagSet

func FlagSet(value uint8, flag uint8) uint8

func FlagUnset

func FlagUnset(value uint8, flag uint8) uint8

func GetCmd

func GetCmd(CmdID uint32) (mainCmdID, subCmdID uint16)

func MakeDWORD

func MakeDWORD(mainCmdID uint16, subCmdID uint16) uint32

Types

type MsgHandler

type MsgHandler func([]interface{})

type MsgInfo

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

type MsgRaw

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

type Processor

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

------------------------- | id | protobuf message | -------------------------

func NewProcessor

func NewProcessor() *Processor

func (*Processor) Cmd2Bytes

func (p *Processor) Cmd2Bytes(mainCmdID uint16, subCmdID uint16) []byte

func (*Processor) Marshal

func (p *Processor) Marshal(recv *RecvMsg, mainCmdID uint16, subCmdID uint16, msg interface{}) ([][]byte, error)

goroutine safe

func (*Processor) MarshalBody

func (p *Processor) MarshalBody(msg interface{}) ([]byte, error)

func (*Processor) MarshalCmd

func (p *Processor) MarshalCmd(recv *RecvMsg, mainCmdID uint16, subCmdID uint16) ([]byte, error)

func (*Processor) Range

func (p *Processor) Range(f func(id uint16, t reflect.Type))

goroutine safe

func (*Processor) Register

func (p *Processor) Register(mainCmdID uint16, subCmdID uint16, msg interface{}) uint32

It's dangerous to call the method on routing or marshaling (unmarshaling)

func (*Processor) Route

func (p *Processor) Route(msg *RecvMsg, userData interface{}) error

goroutine safe

func (*Processor) SetByteOrder

func (p *Processor) SetByteOrder(littleEndian bool)

It's dangerous to call the method on routing or marshaling (unmarshaling)

func (*Processor) SetHandler

func (p *Processor) SetHandler(mainCmdID uint16, subCmdID uint16, msgHandler MsgHandler)

It's dangerous to call the method on routing or marshaling (unmarshaling)

func (*Processor) SetRawHandler

func (p *Processor) SetRawHandler(mainCmdID uint16, subCmdID uint16, msgRawHandler MsgHandler)

It's dangerous to call the method on routing or marshaling (unmarshaling)

func (*Processor) SetRouter

func (p *Processor) SetRouter(mainCmdID uint16, subCmdID uint16, msgRouter *chanrpc.Server)

It's dangerous to call the method on routing or marshaling (unmarshaling)

func (*Processor) Unmarshal

func (p *Processor) Unmarshal(data []byte) (*RecvMsg, error)

goroutine safe

func (*Processor) UnmarshalBody

func (p *Processor) UnmarshalBody(mainCmdID uint16, subCmdID uint16, data []byte) (interface{}, error)

type RecvMsg

type RecvMsg struct {
	RpcCallId uint32
	MsgId     uint32
	Msg       interface{}
	MsgType   uint8
}

Jump to

Keyboard shortcuts

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