This commit is contained in:
aozhiwei 2023-09-09 18:22:32 +08:00
parent f948ec0697
commit 17dbe4c8b7
6 changed files with 45 additions and 36 deletions

View File

@ -19,6 +19,7 @@ type RoomMgr interface {
}
type Player interface {
GetRoom() Room
}
type PlayerMgr interface {

View File

@ -40,30 +40,3 @@ func (this *player) onOffline(){
this.room.OnPlayerOffline(this)
}
}
func (this *player) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
}
func (this *player) CMRoomList(hdr *f5.MsgHdr, msg *cs.CMRoomList) {
}
func (this *player) CMJoinRoom(hdr *f5.MsgHdr, msg *cs.CMJoinRoom) {
}
func (this *player) CMDisbandRoom(hdr *f5.MsgHdr, msg *cs.CMDisbandRoom) {
}
func (this *player) CMLeaveRoom(hdr *f5.MsgHdr, msg *cs.CMLeaveRoom) {
}
func (this *player) CMModifyRoom(hdr *f5.MsgHdr, msg *cs.CMModifyRoom) {
}
func (this *player) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) {
}
func (this *player) CMSetPrepare(hdr *f5.MsgHdr, msg *cs.CMSetPrepare) {
}
func (this *player) CMKickout(hdr *f5.MsgHdr, msg *cs.CMKickout) {
}

View File

@ -2,9 +2,39 @@ package room
import (
"cs"
"f5"
"main/common"
)
type Room struct {
type room struct {
cs.MsgHandlerImpl
}
func (this *room) OnPlayerOffline(hum common.Player) {
}
func (this *room) CMRoomList(hdr *f5.MsgHdr, msg *cs.CMRoomList) {
}
func (this *room) CMJoinRoom(hdr *f5.MsgHdr, msg *cs.CMJoinRoom) {
}
func (this *room) CMDisbandRoom(hdr *f5.MsgHdr, msg *cs.CMDisbandRoom) {
}
func (this *room) CMLeaveRoom(hdr *f5.MsgHdr, msg *cs.CMLeaveRoom) {
}
func (this *room) CMModifyRoom(hdr *f5.MsgHdr, msg *cs.CMModifyRoom) {
}
func (this *room) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) {
}
func (this *room) CMSetPrepare(hdr *f5.MsgHdr, msg *cs.CMSetPrepare) {
}
func (this *room) CMKickout(hdr *f5.MsgHdr, msg *cs.CMKickout) {
}

View File

@ -10,11 +10,11 @@ import (
type roomMgr struct {
cs.MsgHandlerImpl
currRoomId int32
idHash map[int32]*Room
idHash map[int32]*room
}
func (this *roomMgr) Init() {
this.idHash = make(map[int32]*Room)
this.idHash = make(map[int32]*room)
this.currRoomId = 10000
}
@ -23,11 +23,16 @@ func (this *roomMgr) UnInit() {
func (this *roomMgr) ProcessCMMsg(handler *cs.CsNetMsgHandler, hdr *f5.MsgHdr) {
switch handler.HandlerId {
case constant.PLAYER_MGR_HANDLER_ID:
case constant.ROOM_MGR_HANDLER_ID:
cs.DispatchMsg(handler, hdr, this)
case constant.PLAYER_HANDLER_ID:
player := GetPlayerMgr().GetPlayerBySocket(hdr.GetSocket())
if player != nil {
case constant.ROOM_HANDLER_ID:
hum := GetPlayerMgr().GetPlayerBySocket(hdr.GetSocket())
if hum != nil && hum.GetRoom() != nil {
hdr.Context = hum
cs.DispatchMsg(handler, hdr, hum.GetRoom().(*room))
}
}
}
func (this *roomMgr) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
}

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit 35c7b1024790889a4dbc4d98b92e7585b23b291c
Subproject commit 4c371afe631d4818ca8b8f6ba36451b334eb498a

2
third_party/q5 vendored

@ -1 +1 @@
Subproject commit 50a75088aebb09787ee13deb3b6bae6f68c9ab51
Subproject commit a28a913a908b850f10791d8b1f8434a1e2cd308b