Documentation ¶
Index ¶
- Constants
- func GetAllMessageIDs() (msgs []uint32)
- func RegisterMessage(mainID, subID uint16, proc interface{})
- func RegisterMessageRet(session TcpSession) (succ bool, err error)
- func ResponseHeartBeat(session TcpSession) (succ bool, err error)
- func SpecialLoginMsgFilter(main, sub uint16) (ok bool)
- func UnPackExternalMsg(c *kcp.UDPSession, pack IMessagePack) (succ bool)
- func UnPackInnerMsg(c *kcp.UDPSession, pack IMessagePack) (succ bool)
- type IMessagePack
- type KcpClient
- type KcpClientProtocol
- func (this *KcpClientProtocol) Clean()
- func (this *KcpClientProtocol) GetDataLen() (datalen uint32)
- func (this *KcpClientProtocol) GetIdentify() string
- func (this *KcpClientProtocol) GetMessageID() (mainID uint16, subID uint16)
- func (this *KcpClientProtocol) GetPostType() (pt uint16)
- func (this *KcpClientProtocol) GetRemoteAddr() (addr string)
- func (this *KcpClientProtocol) GetRouteID() (route uint16)
- func (this *KcpClientProtocol) GetSrcMsg() (data []byte)
- func (this *KcpClientProtocol) PackAction(Output []byte) (err error)
- func (this *KcpClientProtocol) PackAction4Client(Output []byte) (err error)
- func (this *KcpClientProtocol) PackClientMsg(mainid, subid uint16, msg proto.Message) (out []byte, err error)
- func (this *KcpClientProtocol) PackData(msg proto.Message) (data []byte, err error)
- func (this *KcpClientProtocol) PackInnerMsg(mainid, subid uint16, msg proto.Message) (out []byte, err error)
- func (this *KcpClientProtocol) SetCmd(mainid, subid uint16, data []byte)
- func (this *KcpClientProtocol) SetIdentify(identify string)
- func (this *KcpClientProtocol) SetPostType(pt uint16)
- func (this *KcpClientProtocol) SetRemoteAddr(addr string)
- func (this *KcpClientProtocol) UnPackData() (msg proto.Message, cb reflect.Value, err error, exist bool)
- func (this *KcpClientProtocol) UnPackMsg4Client(InData []byte) (pos int, err error)
- func (this *KcpClientProtocol) UnPackMsg4Svr(InData []byte) (pos int, err error)
- type KcpClientSession
- func (this *KcpClientSession) Alive() bool
- func (this *KcpClientSession) GetIdentify() string
- func (this *KcpClientSession) GetModuleName() string
- func (this *KcpClientSession) GetPack() (obj IMessagePack)
- func (this *KcpClientSession) GetRegPoint() (RegPoint Define.ERouteId)
- func (this *KcpClientSession) GetRemoteAddr() string
- func (this *KcpClientSession) Handler()
- func (this *KcpClientSession) IsUser() bool
- func (this *KcpClientSession) Offline()
- func (this *KcpClientSession) Push(RegPoint Define.ERouteId)
- func (this *KcpClientSession) RefreshHeartBeat(mainid, subid uint16) bool
- func (this *KcpClientSession) SendInnerBroadcastMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpClientSession) SendInnerClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpClientSession) SendInnerSvrMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpClientSession) SendSvrClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpClientSession) SetIdentify(StrIdentify string)
- func (this *KcpClientSession) SetSendCache(data []byte)
- type KcpServer
- type KcpServerProtocol
- func (this *KcpServerProtocol) Clean()
- func (this *KcpServerProtocol) GetDataLen() (datalen uint32)
- func (this *KcpServerProtocol) GetIdentify() string
- func (this *KcpServerProtocol) GetMessageID() (mainID uint16, subID uint16)
- func (this *KcpServerProtocol) GetPostType() (pt uint16)
- func (this *KcpServerProtocol) GetRemoteAddr() (addr string)
- func (this *KcpServerProtocol) GetRouteID() (route uint16)
- func (this *KcpServerProtocol) GetSrcMsg() (data []byte)
- func (this *KcpServerProtocol) PackAction(Output []byte) (err error)
- func (this *KcpServerProtocol) PackAction4Client(Output []byte) (err error)
- func (this *KcpServerProtocol) PackClientMsg(mainid, subid uint16, msg proto.Message) (out []byte, err error)
- func (this *KcpServerProtocol) PackData(msg proto.Message) (data []byte, err error)
- func (this *KcpServerProtocol) PackInnerMsg(mainid, subid uint16, msg proto.Message) (out []byte, err error)
- func (this *KcpServerProtocol) SetCmd(mainid, subid uint16, data []byte)
- func (this *KcpServerProtocol) SetIdentify(identify string)
- func (this *KcpServerProtocol) SetPostType(pt uint16)
- func (this *KcpServerProtocol) SetRemoteAddr(addr string)
- func (this *KcpServerProtocol) UnPackData() (msg proto.Message, cb reflect.Value, err error, exist bool)
- func (this *KcpServerProtocol) UnPackMsg4Client(InData []byte) (pos int, err error)
- func (this *KcpServerProtocol) UnPackMsg4Svr(InData []byte) (pos int, err error)
- type KcpServerSession
- func (this *KcpServerSession) GetIdentify() string
- func (this *KcpServerSession) GetPack() (obj IMessagePack)
- func (this *KcpServerSession) GetRegPoint() (RegPoint Define.ERouteId)
- func (this *KcpServerSession) GetRemoteAddr() string
- func (this *KcpServerSession) Handler()
- func (this *KcpServerSession) Offline()
- func (this *KcpServerSession) Push(RegPoint Define.ERouteId)
- func (this *KcpServerSession) SendInnerBroadcastMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpServerSession) SendInnerClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpServerSession) SendInnerSvrMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpServerSession) SendSvrClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
- func (this *KcpServerSession) SetIdentify(StrIdentify string)
- func (this *KcpServerSession) SetSendCache(data []byte)
- type KcpSvrConfig
- type SessionMgr
- func (this *SessionMgr) AddSession(key interface{}, sess TcpSession)
- func (this *SessionMgr) GetAllSession() (sess sync.Map)
- func (this *SessionMgr) GetSession(key interface{}) (sess TcpSession)
- func (this *SessionMgr) GetSessionByIdentify(key interface{}) (sess TcpSession)
- func (this *SessionMgr) RemoveSession(key interface{}) (succ bool)
- type TMessageProc
- type TcpSession
Constants ¶
View Source
const ( EnMessage_MainIDPackLen = 2 //主命令 EnMessage_SubIDPackLen = 2 //次命令 EnMessage_PostType = 2 //发送类型 EnMessage_DataPackLen = 6 //真实数据长度 (主命令+次命令+发送类型) EnMessage_NoDataLen = 10 //非data数据长度(包体之前的)->(主命令+次命令+发送类型+datalen) //2020.04.15 Identify 会考虑换成 userid 减小包长度 EnMessage_SvrDataPackLen = 50 //真实数据长度 (主命令+次命令+发送类型+ Identify长度 + Identify内容+RemoteAddr 长度+RemoteAddr 内容) EnMessage_SvrNoDataLen = 54 //非data数据长度(包体之前的)->(主命令+次命令+发送类型+ Identify长度 + Identify内容+datalen+RemoteAddr 长度+RemoteAddr 内容) EnMessage_IdentifyEixst = 1 //Identify 长度 EnMessage_IdentifyLen = 21 //Identify 内容 EnMessage_RemoteAddrEixst = 1 //RemoteAddr 长度 EnMessage_RemoteAddrLen = 21 //RemoteAddr 内容 )
- 协议格式,小端字节序
|主命令号 | 次命令号 | 发送类型 |包长度 | 包体 ---------|-------- | -------- | -------- | ---- 2字节 |2字节 | 2字节 | 4字节 | 包体
View Source
const ( MsgPostType_Single = uint16(1) MsgPostType_Broadcast = uint16(2) )
message Post type
Variables ¶
This section is empty.
Functions ¶
func GetAllMessageIDs ¶
func GetAllMessageIDs() (msgs []uint32)
func RegisterMessage ¶
func RegisterMessage(mainID, subID uint16, proc interface{})
func RegisterMessageRet ¶
func RegisterMessageRet(session TcpSession) (succ bool, err error)
func ResponseHeartBeat ¶
func ResponseHeartBeat(session TcpSession) (succ bool, err error)
func SpecialLoginMsgFilter ¶
func UnPackExternalMsg ¶
func UnPackExternalMsg(c *kcp.UDPSession, pack IMessagePack) (succ bool)
@func: UnPackExternalMsg 解服务器外部消息(客户端,clientsession 注册消息) @parma1: 连接对象 c *kcp.UDPSession @param2: 解包对象 pack IMessagePack
func UnPackInnerMsg ¶
func UnPackInnerMsg(c *kcp.UDPSession, pack IMessagePack) (succ bool)
@func: UnPackInnerMsg 解服务器内部消息(server 间客户端发来的请求或者其他rpc消息传递) @parma1: 连接对象 c *kcp.UDPSession @param2: 解包对象 pack IMessagePack
Types ¶
type IMessagePack ¶
type IMessagePack interface { PackAction(Output []byte) (err error) PackAction4Client(Output []byte) (err error) PackData(msg proto.Message) (data []byte, err error) UnPackMsg4Client(InData []byte) (pos int, err error) UnPackData() (msg proto.Message, cb reflect.Value, err error, exist bool) GetRouteID() (route uint16) GetMessageID() (mainID uint16, subID uint16) Clean() SetCmd(mainid, subid uint16, data []byte) PackInnerMsg(mainid, subid uint16, msg proto.Message) (out []byte, err error) PackClientMsg(mainid, subid uint16, msg proto.Message) (out []byte, err error) GetSrcMsg() (data []byte) SetIdentify(identify string) GetIdentify() string UnPackMsg4Svr(InData []byte) (pos int, err error) GetDataLen() (datalen uint32) SetRemoteAddr(addr string) GetRemoteAddr() (addr string) SetPostType(pt uint16) GetPostType() (pt uint16) }
type KcpClient ¶
type KcpClient struct { Addr string // contains filtered or unexported fields }
func NewKcpClient ¶
type KcpClientProtocol ¶
type KcpClientProtocol struct {
// contains filtered or unexported fields
}
model: KcpClientProtocol Client to Server, message
func (*KcpClientProtocol) Clean ¶
func (this *KcpClientProtocol) Clean()
func (*KcpClientProtocol) GetDataLen ¶
func (this *KcpClientProtocol) GetDataLen() (datalen uint32)
func (*KcpClientProtocol) GetIdentify ¶
func (this *KcpClientProtocol) GetIdentify() string
func (*KcpClientProtocol) GetMessageID ¶
func (this *KcpClientProtocol) GetMessageID() (mainID uint16, subID uint16)
func (*KcpClientProtocol) GetPostType ¶
func (this *KcpClientProtocol) GetPostType() (pt uint16)
func (*KcpClientProtocol) GetRemoteAddr ¶
func (this *KcpClientProtocol) GetRemoteAddr() (addr string)
func (*KcpClientProtocol) GetRouteID ¶
func (this *KcpClientProtocol) GetRouteID() (route uint16)
func (*KcpClientProtocol) GetSrcMsg ¶
func (this *KcpClientProtocol) GetSrcMsg() (data []byte)
func (*KcpClientProtocol) PackAction ¶
func (this *KcpClientProtocol) PackAction(Output []byte) (err error)
func (*KcpClientProtocol) PackAction4Client ¶
func (this *KcpClientProtocol) PackAction4Client(Output []byte) (err error)
func (*KcpClientProtocol) PackClientMsg ¶
func (*KcpClientProtocol) PackData ¶
func (this *KcpClientProtocol) PackData(msg proto.Message) (data []byte, err error)
func (*KcpClientProtocol) PackInnerMsg ¶
func (*KcpClientProtocol) SetCmd ¶
func (this *KcpClientProtocol) SetCmd(mainid, subid uint16, data []byte)
func (*KcpClientProtocol) SetIdentify ¶
func (this *KcpClientProtocol) SetIdentify(identify string)
func (*KcpClientProtocol) SetPostType ¶
func (this *KcpClientProtocol) SetPostType(pt uint16)
func (*KcpClientProtocol) SetRemoteAddr ¶
func (this *KcpClientProtocol) SetRemoteAddr(addr string)
func (*KcpClientProtocol) UnPackData ¶
func (*KcpClientProtocol) UnPackMsg4Client ¶
func (this *KcpClientProtocol) UnPackMsg4Client(InData []byte) (pos int, err error)
func (*KcpClientProtocol) UnPackMsg4Svr ¶
func (this *KcpClientProtocol) UnPackMsg4Svr(InData []byte) (pos int, err error)
type KcpClientSession ¶
type KcpClientSession struct {
// contains filtered or unexported fields
}
func (*KcpClientSession) Alive ¶
func (this *KcpClientSession) Alive() bool
func (*KcpClientSession) GetIdentify ¶
func (this *KcpClientSession) GetIdentify() string
func (*KcpClientSession) GetModuleName ¶
func (this *KcpClientSession) GetModuleName() string
func (*KcpClientSession) GetPack ¶
func (this *KcpClientSession) GetPack() (obj IMessagePack)
func (*KcpClientSession) GetRegPoint ¶
func (this *KcpClientSession) GetRegPoint() (RegPoint Define.ERouteId)
func (*KcpClientSession) GetRemoteAddr ¶
func (this *KcpClientSession) GetRemoteAddr() string
func (*KcpClientSession) Handler ¶
func (this *KcpClientSession) Handler()
func (*KcpClientSession) IsUser ¶
func (this *KcpClientSession) IsUser() bool
func (*KcpClientSession) Offline ¶
func (this *KcpClientSession) Offline()
func (*KcpClientSession) Push ¶
func (this *KcpClientSession) Push(RegPoint Define.ERouteId)
func (*KcpClientSession) RefreshHeartBeat ¶
func (this *KcpClientSession) RefreshHeartBeat(mainid, subid uint16) bool
func (*KcpClientSession) SendInnerBroadcastMsg ¶
func (this *KcpClientSession) SendInnerBroadcastMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpClientSession) SendInnerClientMsg ¶
func (this *KcpClientSession) SendInnerClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpClientSession) SendInnerSvrMsg ¶
func (this *KcpClientSession) SendInnerSvrMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpClientSession) SendSvrClientMsg ¶
func (this *KcpClientSession) SendSvrClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpClientSession) SetIdentify ¶
func (this *KcpClientSession) SetIdentify(StrIdentify string)
func (*KcpClientSession) SetSendCache ¶
func (this *KcpClientSession) SetSendCache(data []byte)
type KcpServerProtocol ¶
type KcpServerProtocol struct {
// contains filtered or unexported fields
}
model: KcpServerProtocol server to server, message
func (*KcpServerProtocol) Clean ¶
func (this *KcpServerProtocol) Clean()
func (*KcpServerProtocol) GetDataLen ¶
func (this *KcpServerProtocol) GetDataLen() (datalen uint32)
func (*KcpServerProtocol) GetIdentify ¶
func (this *KcpServerProtocol) GetIdentify() string
func (*KcpServerProtocol) GetMessageID ¶
func (this *KcpServerProtocol) GetMessageID() (mainID uint16, subID uint16)
func (*KcpServerProtocol) GetPostType ¶
func (this *KcpServerProtocol) GetPostType() (pt uint16)
func (*KcpServerProtocol) GetRemoteAddr ¶
func (this *KcpServerProtocol) GetRemoteAddr() (addr string)
func (*KcpServerProtocol) GetRouteID ¶
func (this *KcpServerProtocol) GetRouteID() (route uint16)
func (*KcpServerProtocol) GetSrcMsg ¶
func (this *KcpServerProtocol) GetSrcMsg() (data []byte)
func (*KcpServerProtocol) PackAction ¶
func (this *KcpServerProtocol) PackAction(Output []byte) (err error)
func (*KcpServerProtocol) PackAction4Client ¶
func (this *KcpServerProtocol) PackAction4Client(Output []byte) (err error)
func (*KcpServerProtocol) PackClientMsg ¶
func (*KcpServerProtocol) PackData ¶
func (this *KcpServerProtocol) PackData(msg proto.Message) (data []byte, err error)
func (*KcpServerProtocol) PackInnerMsg ¶
func (*KcpServerProtocol) SetCmd ¶
func (this *KcpServerProtocol) SetCmd(mainid, subid uint16, data []byte)
func (*KcpServerProtocol) SetIdentify ¶
func (this *KcpServerProtocol) SetIdentify(identify string)
func (*KcpServerProtocol) SetPostType ¶
func (this *KcpServerProtocol) SetPostType(pt uint16)
func (*KcpServerProtocol) SetRemoteAddr ¶
func (this *KcpServerProtocol) SetRemoteAddr(addr string)
func (*KcpServerProtocol) UnPackData ¶
func (*KcpServerProtocol) UnPackMsg4Client ¶
func (this *KcpServerProtocol) UnPackMsg4Client(InData []byte) (pos int, err error)
func (*KcpServerProtocol) UnPackMsg4Svr ¶
func (this *KcpServerProtocol) UnPackMsg4Svr(InData []byte) (pos int, err error)
type KcpServerSession ¶
type KcpServerSession struct { RemoteAddr string // contains filtered or unexported fields }
func NewKcpClientSession ¶
func NewKcpClientSession(c *kcp.UDPSession) *KcpServerSession
func NewKcpSvrSession ¶
func NewKcpSvrSession(c *kcp.UDPSession) *KcpServerSession
func (*KcpServerSession) GetIdentify ¶
func (this *KcpServerSession) GetIdentify() string
func (*KcpServerSession) GetPack ¶
func (this *KcpServerSession) GetPack() (obj IMessagePack)
func (*KcpServerSession) GetRegPoint ¶
func (this *KcpServerSession) GetRegPoint() (RegPoint Define.ERouteId)
func (*KcpServerSession) GetRemoteAddr ¶
func (this *KcpServerSession) GetRemoteAddr() string
func (*KcpServerSession) Handler ¶
func (this *KcpServerSession) Handler()
func (*KcpServerSession) Offline ¶
func (this *KcpServerSession) Offline()
func (*KcpServerSession) Push ¶
func (this *KcpServerSession) Push(RegPoint Define.ERouteId)
func (*KcpServerSession) SendInnerBroadcastMsg ¶
func (this *KcpServerSession) SendInnerBroadcastMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpServerSession) SendInnerClientMsg ¶
func (this *KcpServerSession) SendInnerClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpServerSession) SendInnerSvrMsg ¶
func (this *KcpServerSession) SendInnerSvrMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpServerSession) SendSvrClientMsg ¶
func (this *KcpServerSession) SendSvrClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error)
func (*KcpServerSession) SetIdentify ¶
func (this *KcpServerSession) SetIdentify(StrIdentify string)
func (*KcpServerSession) SetSendCache ¶
func (this *KcpServerSession) SetSendCache(data []byte)
type KcpSvrConfig ¶
type KcpSvrConfig struct {
// contains filtered or unexported fields
}
type SessionMgr ¶
type SessionMgr struct {
// contains filtered or unexported fields
}
var ( GServer2ServerSession *SessionMgr GClient2ServerSession *SessionMgr )
func (*SessionMgr) AddSession ¶
func (this *SessionMgr) AddSession(key interface{}, sess TcpSession)
func (*SessionMgr) GetAllSession ¶
func (this *SessionMgr) GetAllSession() (sess sync.Map)
func (*SessionMgr) GetSession ¶
func (this *SessionMgr) GetSession(key interface{}) (sess TcpSession)
func (*SessionMgr) GetSessionByIdentify ¶
func (this *SessionMgr) GetSessionByIdentify(key interface{}) (sess TcpSession)
func (*SessionMgr) RemoveSession ¶
func (this *SessionMgr) RemoveSession(key interface{}) (succ bool)
type TMessageProc ¶
type TMessageProc struct {
// contains filtered or unexported fields
}
func GetMessageInfo ¶
func GetMessageInfo(mainID, subID uint16) (proc *TMessageProc, finded bool)
type TcpSession ¶
type TcpSession interface { GetRemoteAddr() string GetRegPoint() (RegPoint Define.ERouteId) GetIdentify() string SetSendCache(data []byte) Push(RegPoint Define.ERouteId) SetIdentify(StrIdentify string) SendInnerSvrMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error) SendSvrClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error) SendInnerClientMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error) SendInnerBroadcastMsg(mainid, subid uint16, msg proto.Message) (succ bool, err error) WriteMessage(data []byte) (succ bool) Alive() bool GetPack() (obj IMessagePack) IsUser() bool RefreshHeartBeat(mainid, subid uint16) bool GetModuleName() string }
Click to show internal directories.
Click to hide internal directories.