Documentation
¶
Index ¶
- Constants
- Variables
- type IArgs
- type IMsg
- type ISessionVerifyReqMsg
- type ITransportMsg
- type MsgDef
- type TypeMgr
- func (this *TypeMgr) GetMsgDefByID(id uint16) (*MsgDef, error)
- func (this *TypeMgr) GetMsgDefByName(name string) (*MsgDef, error)
- func (this *TypeMgr) GetMsgIDByName(name string) (uint16, error)
- func (this *TypeMgr) GetMsgInfo(msgID uint16) (msgName string, msgContent IMsg, err error)
- func (this *TypeMgr) GetName(msg IMsg) string
- func (this *TypeMgr) GetTypeNameByID(msgID uint16) string
- func (this *TypeMgr) IsMsgExist(msgID uint16) bool
- func (this *TypeMgr) RegisterType(name string, id uint16, v IMsg)
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 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 TypeMgr ¶
type TypeMgr struct {
// contains filtered or unexported fields
}
消息管理器
func GetTypeMgr ¶
func GetTypeMgr() *TypeMgr
func (*TypeMgr) GetMsgDefByName ¶
用名字找结构
func (*TypeMgr) GetMsgInfo ¶
GetMsgInfo 根据消息号,获得消息的类型,名称,如果是protobuf消息,获得proto消息的容器
func (*TypeMgr) GetTypeNameByID ¶
Click to show internal directories.
Click to hide internal directories.