diff --git a/server/hallserver/mt/HallCluster.go b/server/hallserver/mt/HallCluster.go index 8e1e6018..c09aeee7 100644 --- a/server/hallserver/mt/HallCluster.go +++ b/server/hallserver/mt/HallCluster.go @@ -13,6 +13,7 @@ type HallCluster struct { type HallClusterTable struct { f5.IdMetaTable[HallCluster] selfConf *HallCluster + serverInfo string } func (this *HallCluster) Init1() { @@ -31,9 +32,14 @@ func (this *HallClusterTable) GetHttpListenPort() int32 { return this.selfConf.GetHttpListenPort() } +func (this *HallClusterTable) GetServerInfo() string { + return this.serverInfo +} + func (this *HallClusterTable) PostInit1() { this.selfConf = this.GetById(int64(f5.GetApp().GetInstanceId())) if this.selfConf == nil { panic("hallserver集群无法读取本服配置") } + this.serverInfo = this.GetIp() + ":" + q5.ToString(this.GetListenPort()) } diff --git a/server/hallserver/player/player.go b/server/hallserver/player/player.go index d3fe6146..0073ee05 100644 --- a/server/hallserver/player/player.go +++ b/server/hallserver/player/player.go @@ -48,6 +48,14 @@ func (this *player) onOffline(){ } } +func (this *player) reBind(socket f5.WspCliConn) { + if this.socket.IsValid() { + delete(_playerMgr.socketHash, this.socket) + } + this.socket = socket + _playerMgr.socketHash[this.socket] = this +} + func (this *player) GetName() string { return "" } diff --git a/server/hallserver/player/playermgr.go b/server/hallserver/player/playermgr.go index a370c8f3..198d996d 100644 --- a/server/hallserver/player/playermgr.go +++ b/server/hallserver/player/playermgr.go @@ -52,22 +52,26 @@ func (this *playerMgr) UnInit() { func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) { { - oldplayer := this.internalGetPlayerBySocket(hdr.GetSocket()) - if oldplayer != nil { + oldHum := this.internalGetPlayerBySocket(hdr.GetSocket()) + if oldHum != nil { rspMsg := cs.SMLogin{} rspMsg.Errcode = proto.Int32(0) rspMsg.Errmsg = proto.String("") - oldplayer.SendMsg(&rspMsg) + rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo()) + oldHum.reBind(hdr.GetSocket()) + oldHum.SendMsg(&rspMsg) return; } } { - oldplayer := this.internalGetPlayerByAccountId(msg.GetAccountId()) - if oldplayer != nil { + oldHum := this.internalGetPlayerByAccountId(msg.GetAccountId()) + if oldHum != nil { rspMsg := cs.SMLogin{} rspMsg.Errcode = proto.Int32(0) rspMsg.Errmsg = proto.String("") - oldplayer.SendMsg(&rspMsg) + rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo()) + oldHum.reBind(hdr.GetSocket()) + oldHum.SendMsg(&rspMsg) return; } } @@ -155,8 +159,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli this.accountIdHash[hum.GetAccountId()] = hum this.socketHash[pendingReq.hdr.GetSocket()] = hum - rspMsg.ServerInfo = proto.String( - mt.Table.HallCluster.GetIp() + ":" + q5.ToString(mt.Table.HallCluster.GetListenPort())) + rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo()) GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg) } diff --git a/third_party/f5 b/third_party/f5 index bda6cd38..194793c1 160000 --- a/third_party/f5 +++ b/third_party/f5 @@ -1 +1 @@ -Subproject commit bda6cd38df8cf79a43ce3fe027b33936a26ec423 +Subproject commit 194793c17868a2ecc9ada927a8cfecf628152812