From 7952722ee72cc1445daf29b690f7f49925cad0cb Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 2 Dec 2023 21:23:17 +0800 Subject: [PATCH] 1 --- server/matchserver/app/app.go | 6 +-- server/matchserver/listener/httplistener.go | 2 +- server/matchserver/listener/wsplistener.go | 2 +- server/matchserver/mt/HallCluster.go | 49 --------------------- server/matchserver/mt/MatchCluster.go | 49 +++++++++++++++++++++ server/matchserver/mt/export.go | 6 +-- server/matchserver/mtb/mtb.auto_gen.go | 16 +++---- server/matchserver/player/playermgr.go | 10 ++--- server/matchserver/proto/mt.proto | 2 +- 9 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 server/matchserver/mt/HallCluster.go create mode 100644 server/matchserver/mt/MatchCluster.go diff --git a/server/matchserver/app/app.go b/server/matchserver/app/app.go index 59a16ddd..a745202f 100644 --- a/server/matchserver/app/app.go +++ b/server/matchserver/app/app.go @@ -33,8 +33,8 @@ func (this *app) Init() { this.initCb() f5.GetSysLog().Info("%s start host:%s port:%d", this.GetPkgName(), - mt.Table.HallCluster.GetIp(), - mt.Table.HallCluster.GetListenPort()) + mt.Table.MatchCluster.GetIp(), + mt.Table.MatchCluster.GetListenPort()) } func (this *app) UnInit() { @@ -84,5 +84,5 @@ func (this *app) registerDataSources() { } func (this *app) GetHttpListenPort() int32 { - return mt.Table.HallCluster.GetHttpListenPort() + return mt.Table.MatchCluster.GetHttpListenPort() } diff --git a/server/matchserver/listener/httplistener.go b/server/matchserver/listener/httplistener.go index 6849506a..8bac3b48 100644 --- a/server/matchserver/listener/httplistener.go +++ b/server/matchserver/listener/httplistener.go @@ -12,7 +12,7 @@ type httpListener struct { func (this *httpListener) Init() { this.httpServer = new(f5.HttpServer) this.httpServer.Init("hallserver.httplistener", 1000*10) - this.httpServer.Start(mt.Table.HallCluster.GetHttpListenPort()) + this.httpServer.Start(mt.Table.MatchCluster.GetHttpListenPort()) } func (this *httpListener) UnInit() { diff --git a/server/matchserver/listener/wsplistener.go b/server/matchserver/listener/wsplistener.go index 439a8a6f..d76bdc8c 100644 --- a/server/matchserver/listener/wsplistener.go +++ b/server/matchserver/listener/wsplistener.go @@ -25,7 +25,7 @@ type WSPListener struct { func (this *WSPListener) Init() { this.ch = make(chan *f5.MsgHdr) listener, err := net.Listen("tcp", "0.0.0.0:"+ - q5.ToString(mt.Table.HallCluster.GetListenPort())) + q5.ToString(mt.Table.MatchCluster.GetListenPort())) if err != nil { panic(err) } else { diff --git a/server/matchserver/mt/HallCluster.go b/server/matchserver/mt/HallCluster.go deleted file mode 100644 index bbc57539..00000000 --- a/server/matchserver/mt/HallCluster.go +++ /dev/null @@ -1,49 +0,0 @@ -package mt - -import ( - "q5" - "f5" - "mtb" -) - -type HallCluster struct { - mtb.HallCluster -} - -type HallClusterTable struct { - f5.IdMetaTable[HallCluster] - selfConf *HallCluster - serverInfo string -} - -func (this *HallCluster) Init1() { - -} - -func (this *HallClusterTable) GetIp() string { - if f5.IsTestEnv() { - return "127.0.0.1" - } else { - return q5.GetLocalIP() - } -} - -func (this *HallClusterTable) GetListenPort() int32 { - return this.selfConf.GetListenPort() -} - -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/matchserver/mt/MatchCluster.go b/server/matchserver/mt/MatchCluster.go new file mode 100644 index 00000000..73beece6 --- /dev/null +++ b/server/matchserver/mt/MatchCluster.go @@ -0,0 +1,49 @@ +package mt + +import ( + "q5" + "f5" + "mtb" +) + +type MatchCluster struct { + mtb.MatchCluster +} + +type MatchClusterTable struct { + f5.IdMetaTable[MatchCluster] + selfConf *MatchCluster + serverInfo string +} + +func (this *MatchCluster) Init1() { + +} + +func (this *MatchClusterTable) GetIp() string { + if f5.IsTestEnv() { + return "127.0.0.1" + } else { + return q5.GetLocalIP() + } +} + +func (this *MatchClusterTable) GetListenPort() int32 { + return this.selfConf.GetListenPort() +} + +func (this *MatchClusterTable) GetHttpListenPort() int32 { + return this.selfConf.GetHttpListenPort() +} + +func (this *MatchClusterTable) GetServerInfo() string { + return this.serverInfo +} + +func (this *MatchClusterTable) PostInit1() { + this.selfConf = this.GetById(int64(f5.GetApp().GetInstanceId())) + if this.selfConf == nil { + panic("matchserver集群无法读取本服配置") + } + this.serverInfo = this.GetIp() + ":" + q5.ToString(this.GetListenPort()) +} diff --git a/server/matchserver/mt/export.go b/server/matchserver/mt/export.go index a44a0574..ebf8b657 100644 --- a/server/matchserver/mt/export.go +++ b/server/matchserver/mt/export.go @@ -5,14 +5,14 @@ import ( ) type table struct { - HallCluster *HallClusterTable + MatchCluster *MatchClusterTable MasterCluster *MasterClusterTable Config *ConfigTable } var Table = f5.New(func (this* table) { - this.HallCluster = f5.New(func (this *HallClusterTable) { - this.FileName = "../config/hallserver.cluster.json" + this.MatchCluster = f5.New(func (this *MatchClusterTable) { + this.FileName = "../config/matchserver.cluster.json" this.PrimKey = "instance_id" }); diff --git a/server/matchserver/mtb/mtb.auto_gen.go b/server/matchserver/mtb/mtb.auto_gen.go index a765dbdb..28042703 100644 --- a/server/matchserver/mtb/mtb.auto_gen.go +++ b/server/matchserver/mtb/mtb.auto_gen.go @@ -4,7 +4,7 @@ import ( "f5" ) -type HallCluster struct { +type MatchCluster struct { instance_id int32 listen_port int32 http_listen_port int32 @@ -32,27 +32,27 @@ type Config struct { _flags2_ uint64 } -func (this *HallCluster) GetInstanceId() int32 { +func (this *MatchCluster) GetInstanceId() int32 { return this.instance_id } -func (this *HallCluster) HasInstanceId() bool { +func (this *MatchCluster) HasInstanceId() bool { return (this._flags1_ & (uint64(1) << 1)) > 0 } -func (this *HallCluster) GetListenPort() int32 { +func (this *MatchCluster) GetListenPort() int32 { return this.listen_port } -func (this *HallCluster) HasListenPort() bool { +func (this *MatchCluster) HasListenPort() bool { return (this._flags1_ & (uint64(1) << 2)) > 0 } -func (this *HallCluster) GetHttpListenPort() int32 { +func (this *MatchCluster) GetHttpListenPort() int32 { return this.http_listen_port } -func (this *HallCluster) HasHttpListenPort() bool { +func (this *MatchCluster) HasHttpListenPort() bool { return (this._flags1_ & (uint64(1) << 3)) > 0 } @@ -113,7 +113,7 @@ func (this *Config) HasDelayDeleteTime() bool { } -func (this *HallCluster) LoadFromKv(kv map[string]interface{}) { +func (this *MatchCluster) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv) f5.ReadMetaTableField(&this.listen_port, "listen_port", &this._flags1_, 2, kv) f5.ReadMetaTableField(&this.http_listen_port, "http_listen_port", &this._flags1_, 3, kv) diff --git a/server/matchserver/player/playermgr.go b/server/matchserver/player/playermgr.go index 945f1bdf..371ab7ef 100644 --- a/server/matchserver/player/playermgr.go +++ b/server/matchserver/player/playermgr.go @@ -72,7 +72,7 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) { rspMsg := cs.SMLogin{} rspMsg.Errcode = proto.Int32(0) rspMsg.Errmsg = proto.String("") - rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo()) + rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo()) oldHum.reBind(hdr.GetSocket()) oldHum.SendMsg(&rspMsg) GetRoomMgr().RemoveRoomMember(hdr) @@ -86,7 +86,7 @@ func (this *playerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) { rspMsg := cs.SMLogin{} rspMsg.Errcode = proto.Int32(0) rspMsg.Errmsg = proto.String("") - rspMsg.ServerInfo = proto.String(mt.Table.HallCluster.GetServerInfo()) + rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo()) oldHum.reBind(hdr.GetSocket()) oldHum.SendMsg(&rspMsg) GetRoomMgr().RemoveRoomMember(hdr) @@ -181,7 +181,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.GetServerInfo()) + rspMsg.ServerInfo = proto.String(mt.Table.MatchCluster.GetServerInfo()) GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, &rspMsg) GetRoomMgr().RemoveRoomMember(hdr) } @@ -190,8 +190,8 @@ func (this *playerMgr) reportServerState(masterIp string, masterPort int32) { params := map[string]string{ "node_id": q5.ToString(f5.GetApp().GetNodeId()), "instance_id": q5.ToString(f5.GetApp().GetInstanceId()), - "ip": mt.Table.HallCluster.GetIp(), - "port": q5.ToString(mt.Table.HallCluster.GetListenPort()), + "ip": mt.Table.MatchCluster.GetIp(), + "port": q5.ToString(mt.Table.MatchCluster.GetListenPort()), "online_num": q5.ToString(0), "room_num": q5.ToString(0), "channel": q5.ToString(0), diff --git a/server/matchserver/proto/mt.proto b/server/matchserver/proto/mt.proto index f13a33f2..ba02a19f 100644 --- a/server/matchserver/proto/mt.proto +++ b/server/matchserver/proto/mt.proto @@ -2,7 +2,7 @@ package mt; option go_package = ".;mt"; -message HallCluster +message MatchCluster { optional int32 instance_id = 1; optional int32 listen_port = 2;