This commit is contained in:
aozhiwei 2023-12-02 21:23:17 +08:00
parent 4b2eca9989
commit 7952722ee7
9 changed files with 71 additions and 71 deletions

View File

@ -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()
}

View File

@ -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() {

View File

@ -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 {

View File

@ -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())
}

View File

@ -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())
}

View File

@ -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"
});

View File

@ -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)

View File

@ -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),

View File

@ -2,7 +2,7 @@ package mt;
option go_package = ".;mt";
message HallCluster
message MatchCluster
{
optional int32 instance_id = 1;
optional int32 listen_port = 2;