This commit is contained in:
aozhiwei 2023-09-15 16:10:21 +08:00
parent 68454a74fe
commit 9a6fdb07e6
4 changed files with 26 additions and 9 deletions

View File

@ -13,6 +13,7 @@ type HallCluster struct {
type HallClusterTable struct { type HallClusterTable struct {
f5.IdMetaTable[HallCluster] f5.IdMetaTable[HallCluster]
selfConf *HallCluster selfConf *HallCluster
serverInfo string
} }
func (this *HallCluster) Init1() { func (this *HallCluster) Init1() {
@ -31,9 +32,14 @@ func (this *HallClusterTable) GetHttpListenPort() int32 {
return this.selfConf.GetHttpListenPort() return this.selfConf.GetHttpListenPort()
} }
func (this *HallClusterTable) GetServerInfo() string {
return this.serverInfo
}
func (this *HallClusterTable) PostInit1() { func (this *HallClusterTable) PostInit1() {
this.selfConf = this.GetById(int64(f5.GetApp().GetInstanceId())) this.selfConf = this.GetById(int64(f5.GetApp().GetInstanceId()))
if this.selfConf == nil { if this.selfConf == nil {
panic("hallserver集群无法读取本服配置") panic("hallserver集群无法读取本服配置")
} }
this.serverInfo = this.GetIp() + ":" + q5.ToString(this.GetListenPort())
} }

View File

@ -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 { func (this *player) GetName() string {
return "" return ""
} }

View File

@ -52,22 +52,26 @@ func (this *playerMgr) UnInit() {
func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) { func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
{ {
oldplayer := this.internalGetPlayerBySocket(hdr.GetSocket()) oldHum := this.internalGetPlayerBySocket(hdr.GetSocket())
if oldplayer != nil { if oldHum != nil {
rspMsg := cs.SMLogin{} rspMsg := cs.SMLogin{}
rspMsg.Errcode = proto.Int32(0) rspMsg.Errcode = proto.Int32(0)
rspMsg.Errmsg = proto.String("") rspMsg.Errmsg = proto.String("")
oldplayer.SendMsg(&rspMsg) rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo())
oldHum.reBind(hdr.GetSocket())
oldHum.SendMsg(&rspMsg)
return; return;
} }
} }
{ {
oldplayer := this.internalGetPlayerByAccountId(msg.GetAccountId()) oldHum := this.internalGetPlayerByAccountId(msg.GetAccountId())
if oldplayer != nil { if oldHum != nil {
rspMsg := cs.SMLogin{} rspMsg := cs.SMLogin{}
rspMsg.Errcode = proto.Int32(0) rspMsg.Errcode = proto.Int32(0)
rspMsg.Errmsg = proto.String("") rspMsg.Errmsg = proto.String("")
oldplayer.SendMsg(&rspMsg) rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo())
oldHum.reBind(hdr.GetSocket())
oldHum.SendMsg(&rspMsg)
return; return;
} }
} }
@ -155,8 +159,7 @@ func (this *playerMgr) apiAuthCb(hdr *f5.MsgHdr, msg *cs.CMLogin, rsp f5.HttpCli
this.accountIdHash[hum.GetAccountId()] = hum this.accountIdHash[hum.GetAccountId()] = hum
this.socketHash[pendingReq.hdr.GetSocket()] = hum this.socketHash[pendingReq.hdr.GetSocket()] = hum
rspMsg.ServerInfo = proto.String( rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo())
mt.Table.HallCluster.GetIp() + ":" + q5.ToString(mt.Table.HallCluster.GetListenPort()))
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg) GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg)
} }

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit bda6cd38df8cf79a43ce3fe027b33936a26ec423 Subproject commit 194793c17868a2ecc9ada927a8cfecf628152812