This commit is contained in:
aozhiwei 2023-09-07 14:09:02 +08:00
parent 8b5932e123
commit 35740b3891
6 changed files with 37 additions and 13 deletions

View File

@ -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) {

View File

@ -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);
}

View File

@ -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)
}

View File

@ -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
}

View File

@ -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)
}
}
}