msgdef

package
v0.0.0-...-0012533 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessState_New   uint8 = 1 // 新建session
	SessState_ReTry uint8 = 2 // 短线重连的session
)

Variables

View Source
var (
	//没有这个名字的类型
	ErrDef_Not_Exist_Name = common.NewError("def name :%s not exist")
	//没有这个ID的类型
	ErrDef_Not_Exist_ID = common.NewError("def id :%d not exist")
)

Functions

This section is empty.

Types

type IArgs

type IArgs interface {
	// 新的使用字段名就可以更新数据的逻辑
	UpdateField(keyname, field string) error
}

type IMsg

type IMsg interface {
	proto.Message
	Marshal() (dAtA []byte, err error)
	MarshalTo(dAtA []byte) (int, error)
	Unmarshal(dAtA []byte) error
	Size() (n int)
	Name() string
	Descriptor() ([]byte, []int)
}

IMsg 消息接口,所有的消息类都必须实现的接口 本框架对应的proto文件的生成工具中修改过的

type ISessionVerifyReqMsg

type ISessionVerifyReqMsg interface {
	IMsg
	//这个连接所表示的对象唯一ID,如果是服务器就给服务ID,如果是用户就给用户ID
	GetSessUID() uint64
	// 连接状态 1表示对象第一次连接;2表示对象是断线重连
	GetSessState() uint32
	//用于验证的Token,确认身份用的
	GetToken() string
	//服务器类型 连接的类型使用global.ServerTypeEnum
	GetSessType() uint32
}

验证消息的接口,它的实现其实可以使用protobuf

type ITransportMsg

type ITransportMsg interface {
	IMsg
	GetMsgContent() []byte
	GetSrvType() uint8
}

转发消息的接口

type MsgDef

type MsgDef struct {
	MsgID   uint16
	MsgName string
	// TypeName string
	Typ reflect.Type
}

消息反射体

func (*MsgDef) New

func (this *MsgDef) New() interface{}

type TypeMgr

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

消息管理器

func GetTypeMgr

func GetTypeMgr() *TypeMgr

func (*TypeMgr) GetMsgDefByID

func (this *TypeMgr) GetMsgDefByID(id uint16) (*MsgDef, error)

func (*TypeMgr) GetMsgDefByName

func (this *TypeMgr) GetMsgDefByName(name string) (*MsgDef, error)

用名字找结构

func (*TypeMgr) GetMsgIDByName

func (this *TypeMgr) GetMsgIDByName(name string) (uint16, error)

func (*TypeMgr) GetMsgInfo

func (this *TypeMgr) GetMsgInfo(msgID uint16) (msgName string, msgContent IMsg, err error)

GetMsgInfo 根据消息号,获得消息的类型,名称,如果是protobuf消息,获得proto消息的容器

func (*TypeMgr) GetName

func (this *TypeMgr) GetName(msg IMsg) string

func (*TypeMgr) GetTypeNameByID

func (this *TypeMgr) GetTypeNameByID(msgID uint16) string

func (*TypeMgr) IsMsgExist

func (this *TypeMgr) IsMsgExist(msgID uint16) bool

IsMsgExist 消息是否存在

func (*TypeMgr) RegisterType

func (this *TypeMgr) RegisterType(name string, id uint16, v IMsg)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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