1
This commit is contained in:
parent
0253d530ee
commit
b7b090b625
@ -9,24 +9,15 @@ import (
|
||||
"cs"
|
||||
)
|
||||
|
||||
type MsgHdr struct {
|
||||
conn net.Conn
|
||||
msgId int
|
||||
seqId int
|
||||
data []byte
|
||||
msg interface{}
|
||||
entry q5.ListHead
|
||||
}
|
||||
|
||||
type WSPListener_ struct {
|
||||
listener net.Listener
|
||||
ch <-chan *MsgHdr
|
||||
ch <-chan *q5.MsgHdr
|
||||
}
|
||||
|
||||
var WSPListener = new (WSPListener_)
|
||||
|
||||
func (this *WSPListener_) Init() {
|
||||
this.ch = make(chan *MsgHdr)
|
||||
this.ch = make(chan *q5.MsgHdr)
|
||||
listener, err := net.Listen("tcp", "0.0.0.0:8888")
|
||||
if err != nil {
|
||||
|
||||
@ -75,9 +66,9 @@ func (this *WSPListener_) socketRead(conn net.Conn) {
|
||||
if bufLen - offset < 12 + packLen {
|
||||
continue
|
||||
}
|
||||
hdr := new(MsgHdr)
|
||||
hdr.msgId = int(buf[0]) >> 16 + int(buf[1])
|
||||
hdr.seqId = int(buf[0]) >> 16 + int(buf[1])
|
||||
hdr := new(q5.MsgHdr)
|
||||
hdr.MsgId = int(buf[0]) >> 16 + int(buf[1])
|
||||
hdr.SeqId = int(buf[0]) >> 16 + int(buf[1])
|
||||
offset += 12 + packLen
|
||||
} else {
|
||||
warning = true
|
||||
@ -95,8 +86,8 @@ func (this *WSPListener_) socketRead(conn net.Conn) {
|
||||
func (this *WSPListener_) parseNetPkt() {
|
||||
for {
|
||||
if hdr, ok := <-this.ch; ok {
|
||||
hdr.msg = cs.ParsePb(hdr.msgId, hdr.data)
|
||||
if hdr.msg != nil {
|
||||
hdr.Msg = cs.ParsePb(hdr.MsgId, hdr.Data)
|
||||
if hdr.Msg != nil {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ func (this *App_) Update() {
|
||||
}
|
||||
for !this.workList.Empty() {
|
||||
next := this.workList.Next()
|
||||
hdr, ok := next.GetData().(*MsgHdr)
|
||||
hdr, ok := next.GetData().(*q5.MsgHdr)
|
||||
if ok {
|
||||
handlerId := cs.GetMsgHandlerId(hdr.msgId)
|
||||
handlerId := cs.GetMsgHandlerId(hdr.MsgId)
|
||||
if handlerId == PLAYER_MGR_HANDLER_ID {
|
||||
cs.DispatchMsg(hdr.msgId, PlayerMgr)
|
||||
cs.DispatchMsg(hdr.MsgId, PlayerMgr)
|
||||
}
|
||||
}
|
||||
next.Del()
|
||||
@ -76,11 +76,11 @@ func (this *App_) goReportServerState() {
|
||||
}
|
||||
|
||||
|
||||
func (this *App_) addNetMsg(hdr *MsgHdr) {
|
||||
func (this *App_) addNetMsg(hdr *q5.MsgHdr) {
|
||||
{
|
||||
this.msgMutex.Lock()
|
||||
defer this.msgMutex.Unlock()
|
||||
this.msgList.AddTail(&hdr.entry);
|
||||
this.msgList.AddTail(&hdr.Entry);
|
||||
}
|
||||
this.NotifyLoopCond()
|
||||
}
|
||||
|
@ -13,6 +13,12 @@ type MsgHandler interface {
|
||||
type MsgHandlerImpl struct {
|
||||
}
|
||||
|
||||
type NetMsgHandler struct {
|
||||
MsgId int
|
||||
HandlerId int
|
||||
cb func(MsgHandler)
|
||||
}
|
||||
|
||||
func (this *MsgHandlerImpl) CMPing(msg *CMPing) {
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user