This commit is contained in:
aozhiwei 2023-09-09 18:35:39 +08:00
parent 17dbe4c8b7
commit 0810c0847c
3 changed files with 34 additions and 2 deletions

View File

@ -20,6 +20,7 @@ type RoomMgr interface {
type Player interface {
GetRoom() Room
SendMsg(rspMsg proto.Message)
}
type PlayerMgr interface {

View File

@ -12,29 +12,53 @@ type room struct {
}
func (this *room) OnPlayerOffline(hum common.Player) {
}
func (this *room) CMRoomList(hdr *f5.MsgHdr, msg *cs.CMRoomList) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMRoomList{}
hum.SendMsg(&rspMsg)
}
func (this *room) CMJoinRoom(hdr *f5.MsgHdr, msg *cs.CMJoinRoom) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMJoinRoom{}
hum.SendMsg(&rspMsg)
}
func (this *room) CMDisbandRoom(hdr *f5.MsgHdr, msg *cs.CMDisbandRoom) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMDisbandRoom{}
hum.SendMsg(&rspMsg)
}
func (this *room) CMLeaveRoom(hdr *f5.MsgHdr, msg *cs.CMLeaveRoom) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMLeaveRoom{}
hum.SendMsg(&rspMsg)
}
func (this *room) CMModifyRoom(hdr *f5.MsgHdr, msg *cs.CMModifyRoom) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMModifyRoom{}
hum.SendMsg(&rspMsg)
}
func (this *room) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMStartGame{}
hum.SendMsg(&rspMsg)
}
func (this *room) CMSetPrepare(hdr *f5.MsgHdr, msg *cs.CMSetPrepare) {
/*hum := hdr.Context.(common.Player)
rspMsg := cs.SMSetPrepare{}
hum.SendMsg(&rspMsg)*/
}
func (this *room) CMKickout(hdr *f5.MsgHdr, msg *cs.CMKickout) {
/*
hum := hdr.Context.(common.Player)
rspMsg := cs.SMkickout{}
hum.SendMsg(&rspMsg)*/
}

View File

@ -4,6 +4,7 @@ import (
"cs"
"f5"
"main/constant"
"main/common"
. "main/global"
)
@ -24,7 +25,10 @@ func (this *roomMgr) UnInit() {
func (this *roomMgr) ProcessCMMsg(handler *cs.CsNetMsgHandler, hdr *f5.MsgHdr) {
switch handler.HandlerId {
case constant.ROOM_MGR_HANDLER_ID:
cs.DispatchMsg(handler, hdr, this)
hum := GetPlayerMgr().GetPlayerBySocket(hdr.GetSocket())
if hum != nil {
cs.DispatchMsg(handler, hdr, this)
}
case constant.ROOM_HANDLER_ID:
hum := GetPlayerMgr().GetPlayerBySocket(hdr.GetSocket())
if hum != nil && hum.GetRoom() != nil {
@ -35,4 +39,7 @@ func (this *roomMgr) ProcessCMMsg(handler *cs.CsNetMsgHandler, hdr *f5.MsgHdr) {
}
func (this *roomMgr) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
hum := hdr.Context.(common.Player)
rspMsg := cs.SMCreateRoom{}
hum.SendMsg(&rspMsg)
}