This commit is contained in:
aozhiwei 2023-09-12 13:48:17 +08:00
parent d2607bec10
commit a6413c9ab2
6 changed files with 34 additions and 3 deletions

View File

@ -22,6 +22,7 @@ type Player interface {
GetRoom() Room GetRoom() Room
SetRoom(Room) SetRoom(Room)
GetAccountId() string GetAccountId() string
GetSessionId() string
GetName() string GetName() string
GetAvatarUrl() string GetAvatarUrl() string
GetHeroId() int32 GetHeroId() int32

View File

@ -74,3 +74,7 @@ func (this *player) GetZoneId() int32 {
func (this *player) GetNodeId() int32 { func (this *player) GetNodeId() int32 {
return 0 return 0
} }
func (this *player) GetSessionId() string {
return this.sessionId
}

View File

@ -238,3 +238,25 @@ func (this *playerMgr) SS_WSP_SocketDisconnect(hdr *f5.MsgHdr, msg *ss.SS_WSP_So
delete(this.socketHash, hdr.GetSocket()) delete(this.socketHash, hdr.GetSocket())
hum.onOffline() hum.onOffline()
} }
func (this *playerMgr) CMReconnect(hdr *f5.MsgHdr, msg *cs.CMReconnect) {
hum := this.internalGetPlayerByAccountId(msg.GetAccountId())
rspMsg := &cs.SMReconnect{}
if hum == nil {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("")
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
return
}
if hum.GetSessionId() != msg.GetSessionId() {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("")
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
return
}
if hum.socket.IsValid() {
delete(this.socketHash, hum.socket)
}
this.socketHash[hdr.GetSocket()] = hum
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}

View File

@ -181,7 +181,8 @@ message SMReconnect
// //
message CMCreateRoom message CMCreateRoom
{ {
optional string passwd = 1; // optional int32 map_id = 1; //id
optional string passwd = 2; //
} }
message SMCreateRoom message SMCreateRoom

View File

@ -29,10 +29,13 @@ type room struct {
startTimer *f5.TimerWp startTimer *f5.TimerWp
} }
func (this *room) init(roomId string, roomIdx int64, owner common.Player, passwd string) { func (this *room) init(roomId string, roomIdx int64, mapId int32, owner common.Player, passwd string) {
this.roomId = roomId this.roomId = roomId
this.roomIdx = roomIdx this.roomIdx = roomIdx
this.entry.Init(this) this.entry.Init(this)
this.config.mapId = mapId
this.config.zoneId = owner.GetZoneId()
this.config.nodeId = owner.GetNodeId()
this.config.passwd = passwd this.config.passwd = passwd
this.owner = newMember(owner) this.owner = newMember(owner)
this.members = map[string]*member{ this.members = map[string]*member{

View File

@ -62,7 +62,7 @@ func (this *roomMgr) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
return return
} }
m := new(room) m := new(room)
m.init(q5.ToString(this.genRoomId()), this.genRoomIdx(), hum, msg.GetPasswd()) m.init(q5.ToString(this.genRoomId()), this.genRoomIdx(), msg.GetMapId(), hum, msg.GetPasswd())
this.idHash[m.roomId] = m this.idHash[m.roomId] = m
hum.SendMsg(rspMsg) hum.SendMsg(rspMsg)