codec

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Merge = proto.Merge
	Clone = proto.Clone
)

Functions

func Clear

func Clear()

func CreateMessageByID

func CreateMessageByID(msgId uint32) proto.Message

CreateMessageByID 根据消息ID创建消息(使用反射)

func CreateMessageByName

func CreateMessageByName(fullName string) proto.Message

CreateMessageByName 根据消息名称创建消息(使用反射)

func CreatePairingAck

func CreatePairingAck(reqName string) proto.Message

func GetMessageFullName

func GetMessageFullName(msgId uint32) string

GetMessageFullName 根据消息ID获取消息名称

func GetMessageId

func GetMessageId(fullName string) uint32

GetMessageId 根据消息名称获取消息ID

func GetMessageIdOf

func GetMessageIdOf(msg proto.Message) uint32

GetMessageIdOf 获取proto消息的ID

func GetMessageShortName

func GetMessageShortName(msgId uint32) string

func GetMessageType

func GetMessageType(msgId uint32) reflect.Type

func GetPairingAckName

func GetPairingAckName(reqName string) string

GetPairingAckName 根据Req消息名称,返回其对应的Ack消息名称

func GetPairingAckNameOf

func GetPairingAckNameOf(msgId uint32) string

func HasValidSuffix

func HasValidSuffix(name string) bool

HasValidSuffix 指定的后缀才自动注册

func IsAckMessage

func IsAckMessage(name string) bool

func IsReqMessage

func IsReqMessage(name string) bool

func Marshal

func Marshal(m proto.Message) ([]byte, error)

func MarshalProtoJSON

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

MarshalProtoJSON 序列化proto消息为json格式

func NameHash

func NameHash(name string) uint32

NameHash 计算字符串的hash值

func Register

func Register(fullname string) error

func RegisterAllMessages

func RegisterAllMessages()

RegisterAllMessages 自动注册所有protobuf消息 protobuf使用init()注册(RegisterType),则此API需要在import后调用

func Unmarshal

func Unmarshal(b []byte, m Message) error

func UnmarshalProtoJSON

func UnmarshalProtoJSON(b []byte, m proto.Message) error

Types

type Message

type Message = proto.Message

type VTProtoMessage

type VTProtoMessage interface {
	SizeVT() int
	MarshalVT() ([]byte, error)
	MarshalToVT(data []byte) (int, error)
	MarshalToSizedBufferVT(data []byte) (int, error)
	UnmarshalVT([]byte) error
}

Jump to

Keyboard shortcuts

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