From 35740b3891f34b69035b43c177809e658dbd01bf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 7 Sep 2023 14:09:02 +0800 Subject: [PATCH] 1 --- server/hallserver/app/app.go | 14 ++++++-------- server/hallserver/common/types.go | 11 ++++++++++- server/hallserver/listener/wsplistener.go | 4 ++++ server/hallserver/player/player.go | 6 +++--- server/hallserver/player/playermgr.go | 13 +++++++++++++ server/hallserver/ss/ss.auto_gen.go | 2 +- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/server/hallserver/app/app.go b/server/hallserver/app/app.go index 5d79a08b..590d3c6d 100644 --- a/server/hallserver/app/app.go +++ b/server/hallserver/app/app.go @@ -4,7 +4,10 @@ import ( "f5" "q5" "mt" + "cs" + "ss" . "main/common" + . "main/global" ) type app struct { @@ -35,7 +38,6 @@ func (this *app) UnInit() { func (this *app) Update() { this.netMsgQueue.Fetch() - /* for !this.netMsgQueue.WorkList.Empty() { next := this.netMsgQueue.WorkList.Next() hdr, ok := next.GetData().(*f5.MsgHdr) @@ -45,7 +47,7 @@ func (this *app) Update() { if handler != nil { switch handler.HandlerId { case WSP_LISTENER_HANDLER_ID: - ss.DispatchMsg(handler, hdr, wspListener) + GetWspListener().ProcessSSMMsg(handler, hdr) } } } else { @@ -53,18 +55,14 @@ func (this *app) Update() { if handler != nil { switch handler.HandlerId { case PLAYER_MGR_HANDLER_ID: - cs.DispatchMsg(handler, hdr, playerMgr) case PLAYER_HANDLER_ID: - player := playerMgr.getPlayerBySocket(hdr.GetSocket()) - if player != nil { - cs.DispatchMsg(handler, hdr, player) - } + GetPlayerMgr().ProcessCMMsg(handler, hdr) } } } } next.Del() - }*/ + } } func (this *app) addNetMsg(hdr *f5.MsgHdr) { diff --git a/server/hallserver/common/types.go b/server/hallserver/common/types.go index e3bc792c..e9de6de6 100644 --- a/server/hallserver/common/types.go +++ b/server/hallserver/common/types.go @@ -3,6 +3,10 @@ package common import ( "net" + "cs" + "ss" + "f5" + proto "github.com/golang/protobuf/proto" ) @@ -19,11 +23,16 @@ type RoomMgr interface { } -type PlayerMgr interface { +type Player interface { +} +type PlayerMgr interface { + ProcessCMMsg(*cs.CsNetMsgHandler, *f5.MsgHdr) } type WspListener interface { + ss.MsgHandler + ProcessSSMMsg(*ss.SsNetMsgHandler, *f5.MsgHdr) SendProxyMsg(net.Conn, uint16, proto.Message); } diff --git a/server/hallserver/listener/wsplistener.go b/server/hallserver/listener/wsplistener.go index 15bf7935..47be9403 100644 --- a/server/hallserver/listener/wsplistener.go +++ b/server/hallserver/listener/wsplistener.go @@ -169,3 +169,7 @@ func (this *WSPListener) SendProxyMsg(conn net.Conn, socketHandle uint16, msg pr copy(buff[f5.WSPROXYPACKHEAD_S_SIZE:], msgData[:]) conn.Write(buff) } + +func (this* WSPListener) ProcessSSMMsg(handler *ss.SsNetMsgHandler, hdr *f5.MsgHdr) { + ss.DispatchMsg(handler, hdr, this) +} diff --git a/server/hallserver/player/player.go b/server/hallserver/player/player.go index 76d6b3d7..3b661b33 100644 --- a/server/hallserver/player/player.go +++ b/server/hallserver/player/player.go @@ -4,7 +4,7 @@ import ( "cs" "f5" "github.com/golang/protobuf/proto" - . "main/common" + "main/common" ) type Player struct { @@ -12,7 +12,7 @@ type Player struct { socket f5.WspCliConn accountId string sessionId string - room *Room + room *common.Room } func (this *Player) GetAccountId() string { @@ -23,6 +23,6 @@ func (this *Player) SendMsg(rspMsg proto.Message) { //wspListener.sendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg) } -func (this *Player) GetRoom() *Room { +func (this *Player) GetRoom() *common.Room { return this.room } diff --git a/server/hallserver/player/playermgr.go b/server/hallserver/player/playermgr.go index dce64464..1b4bff51 100644 --- a/server/hallserver/player/playermgr.go +++ b/server/hallserver/player/playermgr.go @@ -7,6 +7,7 @@ import ( "fmt" "mt" "q5" + "main/common" ) type playerMgr struct { @@ -136,3 +137,15 @@ func (this *playerMgr) getPlayerBySocket(socket f5.WspCliConn) *Player { func (this *playerMgr) addSocketHash(wsp f5.WspCliConn, p *Player) { this.socketHash[wsp] = p } + +func (this* playerMgr) ProcessCMMsg(handler *cs.CsNetMsgHandler, hdr *f5.MsgHdr) { + switch handler.HandlerId { + case common.PLAYER_MGR_HANDLER_ID: + cs.DispatchMsg(handler, hdr, this) + case common.PLAYER_HANDLER_ID: + player := this.getPlayerBySocket(hdr.GetSocket()) + if player != nil { + cs.DispatchMsg(handler, hdr, player) + } + } +} diff --git a/server/hallserver/ss/ss.auto_gen.go b/server/hallserver/ss/ss.auto_gen.go index d9564a55..bad7261a 100644 --- a/server/hallserver/ss/ss.auto_gen.go +++ b/server/hallserver/ss/ss.auto_gen.go @@ -119,4 +119,4 @@ func init() { }, } -} \ No newline at end of file +}