完善文档

This commit is contained in:
flswld
2022-12-30 18:27:51 +08:00
parent 6fd3d6a349
commit 2bc157dd2d
22 changed files with 467 additions and 233 deletions

View File

@@ -6,18 +6,31 @@ hk4e game server
* Go >= 1.18 * Go >= 1.18
1. 首次需要安装工具 `make dev_tool` > 1. 首次需要安装工具 `make dev_tool`
2. 生成协议 `make gen` > 2. 生成协议 `make gen`
## 快速运行 ## 快速运行
#### 第三方组件
* mongodb * mongodb
* nats-server * nats-server
* redis
1. 启动节点服务器(仅单节点) `cmd/node && go run .` #### 启动顺序
2. 启动http登录服务器(可多节点) `cmd/dispatch && go run .`
3. 启动网关服务器(可多节点) `cd cmd/gate && go run .` > 1. 启动节点服务器(仅单节点 有状态) `cmd/node && go run .`
4. 启动战斗服务器(可多节点) `cmd/fight && go run .` > 2. 启动http登录服务器(可多节点 无状态) `cmd/dispatch && go run .`
5. 启动寻路服务器(可多节点) `cmd/pathfinding && go run .` > 3. 启动网关服务器(可多节点 有状态) `cd cmd/gate && go run .`
6. 启动游戏服务器(可多节点) `cd cmd/gs && go run .` > 4. 启动战斗服务器(可多节点 有状态) `cmd/fight && go run .`
7. 启动游戏管理服务器(仅单节点) `cmd/gm && go run .` > 5. 启动寻路服务器(可多节点 无状态) `cmd/pathfinding && go run .`
> 6. 启动游戏服务器(可多节点 有状态) `cd cmd/gs && go run .`
> 7. 启动游戏管理服务器(仅单节点 无状态) `cmd/gm && go run .`
#### 其它
* 配置运行时环境变量
```shell
GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore
```

View File

@@ -18,10 +18,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
go func() { go func() {
err := statsviz_serve.Serve("0.0.0.0:2345") _ = statsviz_serve.Serve("0.0.0.0:2345")
if err != nil {
panic(err)
}
}() }()
err := app.Run(context.TODO(), *config) err := app.Run(context.TODO(), *config)
if err != nil { if err != nil {

View File

@@ -1,7 +1,8 @@
[hk4e] [hk4e]
kcp_addr = "127.0.0.1" kcp_addr = "127.0.0.1" # 该地址只用来注册到节点服务器 并非网关本地监听地址 本地监听为0.0.0.0
kcp_port = 22103 kcp_port = 22103
client_proto_proxy_enable = false client_proto_proxy_enable = false
version = "320"
[logger] [logger]
level = "DEBUG" level = "DEBUG"

View File

@@ -38,12 +38,13 @@ type Redis struct {
// Hk4e 原神相关 // Hk4e 原神相关
type Hk4e struct { type Hk4e struct {
KcpPort int32 `toml:"kcp_port"` KcpPort int32 `toml:"kcp_port"` // 该地址只用来注册到节点服务器 并非网关本地监听地址 本地监听为0.0.0.0
KcpAddr string `toml:"kcp_addr"` KcpAddr string `toml:"kcp_addr"`
ResourcePath string `toml:"resource_path"` ResourcePath string `toml:"resource_path"`
GameDataConfigPath string `toml:"game_data_config_path"` GameDataConfigPath string `toml:"game_data_config_path"`
GachaHistoryServer string `toml:"gacha_history_server"` GachaHistoryServer string `toml:"gacha_history_server"`
ClientProtoProxyEnable bool `toml:"client_proto_proxy_enable"` ClientProtoProxyEnable bool `toml:"client_proto_proxy_enable"`
Version string `toml:"version"`
} }
// MQ 消息队列 // MQ 消息队列

View File

@@ -19,6 +19,7 @@ import (
) )
func (c *Controller) query_security_file(context *gin.Context) { func (c *Controller) query_security_file(context *gin.Context) {
// 很早以前2.6.0版本的时候抓包为了完美还原写的 不清楚有没有副作用暂时不要了
return return
file, err := os.ReadFile("static/security_file") file, err := os.ReadFile("static/security_file")
if err != nil { if err != nil {
@@ -35,22 +36,11 @@ func (c *Controller) query_region_list(context *gin.Context) {
_, _ = context.Writer.WriteString(regionListBase64) _, _ = context.Writer.WriteString(regionListBase64)
} }
func (c *Controller) query_cur_region(context *gin.Context) { func (c *Controller) getClientVersionByName(versionName string) (int, string) {
versionName := context.Query("version")
response := "CAESGE5vdCBGb3VuZCB2ZXJzaW9uIGNvbmZpZw=="
if len(context.Request.URL.RawQuery) > 0 {
addr, err := c.discovery.GetGateServerAddr(context.Request.Context(), &api.NullMsg{})
if err != nil {
logger.Error("get gate server addr error: %v", err)
return
}
regionCurrBase64 := region.GetRegionCurrBase64(addr.IpAddr, int32(addr.Port), c.ec2b)
response = regionCurrBase64
}
reg, err := regexp.Compile("[0-9]+") reg, err := regexp.Compile("[0-9]+")
if err != nil { if err != nil {
logger.Error("compile regexp error: %v", err) logger.Error("compile regexp error: %v", err)
return return 0, ""
} }
versionSlice := reg.FindAllString(versionName, -1) versionSlice := reg.FindAllString(versionName, -1)
version := 0 version := 0
@@ -58,7 +48,7 @@ func (c *Controller) query_cur_region(context *gin.Context) {
v, err := strconv.Atoi(versionSlice[index]) v, err := strconv.Atoi(versionSlice[index])
if err != nil { if err != nil {
logger.Error("parse client version error: %v", err) logger.Error("parse client version error: %v", err)
return return 0, ""
} }
for i := 0; i < len(versionSlice)-1-index; i++ { for i := 0; i < len(versionSlice)-1-index; i++ {
v *= 10 v *= 10
@@ -69,88 +59,126 @@ func (c *Controller) query_cur_region(context *gin.Context) {
// 测试版本 // 测试版本
version /= 10 version /= 10
} }
if version >= 275 { return version, strconv.Itoa(version)
logger.Debug("do hk4e 2.8 rsa logic") }
if context.Query("dispatchSeed") == "" {
rsp := &httpapi.QueryCurRegionRspJson{ func (c *Controller) query_cur_region(context *gin.Context) {
Content: response, rspError := func() {
Sign: "TW9yZSBsb3ZlIGZvciBVQSBQYXRjaCBwbGF5ZXJz", rspContentError := "CAESGE5vdCBGb3VuZCB2ZXJzaW9uIGNvbmZpZw=="
} rspSignError := "TW9yZSBsb3ZlIGZvciBVQSBQYXRjaCBwbGF5ZXJz"
context.JSON(http.StatusOK, rsp)
return
}
keyId := context.Query("key_id")
encPubPrivKey, exist := c.encRsaKeyMap[keyId]
if !exist {
logger.Error("can not found key id: %v", keyId)
return
}
regionInfo, err := base64.StdEncoding.DecodeString(response)
if err != nil {
logger.Error("decode region info error: %v", err)
return
}
chunkSize := 256 - 11
regionInfoLength := len(regionInfo)
numChunks := int(math.Ceil(float64(regionInfoLength) / float64(chunkSize)))
encryptedRegionInfo := make([]byte, 0)
for i := 0; i < numChunks; i++ {
from := i * chunkSize
to := int(math.Min(float64((i+1)*chunkSize), float64(regionInfoLength)))
chunk := regionInfo[from:to]
pubKey, err := endec.RsaParsePubKeyByPrivKey(encPubPrivKey)
if err != nil {
logger.Error("parse rsa pub key error: %v", err)
return
}
privKey, err := endec.RsaParsePrivKey(encPubPrivKey)
if err != nil {
logger.Error("parse rsa priv key error: %v", err)
return
}
encrypt, err := endec.RsaEncrypt(chunk, pubKey)
if err != nil {
logger.Error("rsa enc error: %v", err)
return
}
decrypt, err := endec.RsaDecrypt(encrypt, privKey)
if err != nil {
logger.Error("rsa dec error: %v", err)
return
}
if bytes.Compare(decrypt, chunk) != 0 {
logger.Error("rsa dec test fail")
return
}
encryptedRegionInfo = append(encryptedRegionInfo, encrypt...)
}
signPrivkey, err := endec.RsaParsePrivKey(c.signRsaKey)
if err != nil {
logger.Error("parse rsa priv key error: %v", err)
return
}
signData, err := endec.RsaSign(regionInfo, signPrivkey)
if err != nil {
logger.Error("rsa sign error: %v", err)
return
}
ok, err := endec.RsaVerify(regionInfo, signData, &signPrivkey.PublicKey)
if err != nil {
logger.Error("rsa verify error: %v", err)
return
}
if !ok {
logger.Error("rsa verify test fail")
return
}
rsp := &httpapi.QueryCurRegionRspJson{ rsp := &httpapi.QueryCurRegionRspJson{
Content: base64.StdEncoding.EncodeToString(encryptedRegionInfo), Content: rspContentError,
Sign: base64.StdEncoding.EncodeToString(signData), Sign: rspSignError,
} }
context.JSON(http.StatusOK, rsp) context.JSON(http.StatusOK, rsp)
return
} else {
context.Header("Content-type", "text/html; charset=UTF-8")
_, _ = context.Writer.WriteString(response)
} }
versionName := context.Query("version")
if versionName == "" {
rspError()
return
}
version, versionStr := c.getClientVersionByName(versionName)
if version == 0 {
rspError()
return
}
addr, err := c.discovery.GetGateServerAddr(context.Request.Context(), &api.GetGateServerAddrReq{
Version: versionStr,
})
if err != nil {
logger.Error("get gate server addr error: %v", err)
rspError()
return
}
regionCurrBase64 := region.GetRegionCurrBase64(addr.IpAddr, int32(addr.Port), c.ec2b)
if version < 275 {
context.Header("Content-type", "text/html; charset=UTF-8")
_, _ = context.Writer.WriteString(regionCurrBase64)
return
}
logger.Debug("do hk4e 2.8 rsa logic")
if context.Query("dispatchSeed") == "" {
rspError()
return
}
keyId := context.Query("key_id")
encPubPrivKey, exist := c.encRsaKeyMap[keyId]
if !exist {
logger.Error("can not found key id: %v", keyId)
rspError()
return
}
regionInfo, err := base64.StdEncoding.DecodeString(regionCurrBase64)
if err != nil {
logger.Error("decode region info error: %v", err)
rspError()
return
}
chunkSize := 256 - 11
regionInfoLength := len(regionInfo)
numChunks := int(math.Ceil(float64(regionInfoLength) / float64(chunkSize)))
encryptedRegionInfo := make([]byte, 0)
for i := 0; i < numChunks; i++ {
from := i * chunkSize
to := int(math.Min(float64((i+1)*chunkSize), float64(regionInfoLength)))
chunk := regionInfo[from:to]
pubKey, err := endec.RsaParsePubKeyByPrivKey(encPubPrivKey)
if err != nil {
logger.Error("parse rsa pub key error: %v", err)
rspError()
return
}
privKey, err := endec.RsaParsePrivKey(encPubPrivKey)
if err != nil {
logger.Error("parse rsa priv key error: %v", err)
rspError()
return
}
encrypt, err := endec.RsaEncrypt(chunk, pubKey)
if err != nil {
logger.Error("rsa enc error: %v", err)
rspError()
return
}
decrypt, err := endec.RsaDecrypt(encrypt, privKey)
if err != nil {
logger.Error("rsa dec error: %v", err)
rspError()
return
}
if bytes.Compare(decrypt, chunk) != 0 {
logger.Error("rsa dec test fail")
rspError()
return
}
encryptedRegionInfo = append(encryptedRegionInfo, encrypt...)
}
signPrivkey, err := endec.RsaParsePrivKey(c.signRsaKey)
if err != nil {
logger.Error("parse rsa priv key error: %v", err)
rspError()
return
}
signData, err := endec.RsaSign(regionInfo, signPrivkey)
if err != nil {
logger.Error("rsa sign error: %v", err)
rspError()
return
}
ok, err := endec.RsaVerify(regionInfo, signData, &signPrivkey.PublicKey)
if err != nil {
logger.Error("rsa verify error: %v", err)
rspError()
return
}
if !ok {
logger.Error("rsa verify test fail")
rspError()
return
}
rsp := &httpapi.QueryCurRegionRspJson{
Content: base64.StdEncoding.EncodeToString(encryptedRegionInfo),
Sign: base64.StdEncoding.EncodeToString(signData),
}
context.JSON(http.StatusOK, rsp)
} }

BIN
doc/HK4E登录流程.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

1
doc/README.md Normal file
View File

@@ -0,0 +1 @@
# 关于框架的一些小说明

View File

@@ -36,6 +36,16 @@ func Run(ctx context.Context, configFile string) error {
return err return err
} }
APPID = rsp.GetAppId() APPID = rsp.GetAppId()
go func() {
ticker := time.NewTicker(time.Second * 15)
for {
<-ticker.C
_, _ = client.Discovery.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
ServerType: api.FIGHT,
AppId: APPID,
})
}
}()
defer func() { defer func() {
_, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{ _, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{
ServerType: api.FIGHT, ServerType: api.FIGHT,

View File

@@ -238,6 +238,10 @@ func (f *FightRoutine) attackHandle(gameMsg *mq.GameMsg) {
continue continue
} }
attackResult := hitInfo.AttackResult attackResult := hitInfo.AttackResult
if attackResult == nil {
logger.Error("attackResult is nil")
continue
}
// logger.Debug("run attack handler, attackResult: %v", attackResult) // logger.Debug("run attack handler, attackResult: %v", attackResult)
target := f.entityMap[attackResult.DefenseId] target := f.entityMap[attackResult.DefenseId]
if target == nil { if target == nil {

View File

@@ -34,11 +34,22 @@ func Run(ctx context.Context, configFile string) error {
IpAddr: config.CONF.Hk4e.KcpAddr, IpAddr: config.CONF.Hk4e.KcpAddr,
Port: uint32(config.CONF.Hk4e.KcpPort), Port: uint32(config.CONF.Hk4e.KcpPort),
}, },
Version: config.CONF.Hk4e.Version,
}) })
if err != nil { if err != nil {
return err return err
} }
APPID = rsp.GetAppId() APPID = rsp.GetAppId()
go func() {
ticker := time.NewTicker(time.Second * 15)
for {
<-ticker.C
_, _ = client.Discovery.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
ServerType: api.GATE,
AppId: APPID,
})
}
}()
defer func() { defer func() {
_, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{ _, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{
ServerType: api.GATE, ServerType: api.GATE,

View File

@@ -2,15 +2,14 @@
## 功能介绍 ## 功能介绍
### 开启本功能后,网关服务器以及游戏服务器等其他服务器,将预先对客户端上行和服务器下行的协议数据做前置转换,采用任意版本的协议文件(必要字段名必须与现有的协议保持一致)均可,避免了因协议序号混淆等频繁变动,而造成游戏服务器代码不必要的频繁改动 #### 开启本功能后,网关服务器以及游戏服务器等其他服务器,将预先对客户端上行和服务器下行的协议数据做前置转换,采用任意版本的协议文件(必要字段名必须与现有的协议保持一致)均可,避免了因协议序号混淆等频繁变动,而造成游戏服务器代码不必要的频繁改动
## 使用方法 ## 使用方法
1. 在此目录下建立bin目录和proto目录 > 1. 在此目录下建立bin目录和proto目录
2.client_cmd.csv文件放到bin目录下 > 2. 将对应版本的proto协议文件复制到proto目录下并编译成pb.go
3.对应版本的proto协议文件复制到proto目录下并编译成pb.go > 3. 将client_proto_gen_test.go的TestClientProtoGen方法添加运行配置
4.client_proto_gen_test.go的TestClientProtoGen方法添加运行配置 > 4. 将运行配置输出目录和工作目录都设置为bin目录
5. 将运行配置输出目录和工作目录都设置为bin目录 > 5. 运行并生成client_proto_gen.go
6. 运行并生成client_proto_gen.go > 6. 将client_cmd.csv放入gate和gs和fight服务器的运行目录下
7.client_cmd.csv放入gate和gs和fight服务器的运行目录下 > 7. 将gate和gs和fight服务器的配置文件中开启client_proto_proxy_enable客户端协议代理功能
8. 将gate和gs和fight服务器的配置文件中开启client_proto_proxy_enable客户端协议代理功能

View File

@@ -14,9 +14,8 @@ func TestClientProtoGen(t *testing.T) {
nameList := make([]string, 0) nameList := make([]string, 0)
for _, entry := range dir { for _, entry := range dir {
split := strings.Split(entry.Name(), ".") split := strings.Split(entry.Name(), ".")
if len(split) != 2 { if len(split) != 2 || split[1] != "proto" {
continue continue
//panic("file name error")
} }
nameList = append(nameList, split[0]) nameList = append(nameList, split[0])
} }

View File

@@ -295,7 +295,7 @@ func (k *KcpConnectManager) getPlayerToken(req *proto.GetPlayerTokenReq, session
} }
oldSession := k.GetSessionByUserId(tokenVerifyRsp.PlayerID) oldSession := k.GetSessionByUserId(tokenVerifyRsp.PlayerID)
if oldSession != nil { if oldSession != nil {
// 顶号 // 本地顶号
kickFinishNotifyChan := make(chan bool) kickFinishNotifyChan := make(chan bool)
k.kcpEventInput <- &KcpEvent{ k.kcpEventInput <- &KcpEvent{
ConvId: oldSession.conn.GetConv(), ConvId: oldSession.conn.GetConv(),
@@ -303,6 +303,18 @@ func (k *KcpConnectManager) getPlayerToken(req *proto.GetPlayerTokenReq, session
EventMessage: kickFinishNotifyChan, EventMessage: kickFinishNotifyChan,
} }
<-kickFinishNotifyChan <-kickFinishNotifyChan
} else {
// 远程全局顶号
connCtrlMsg := new(mq.ConnCtrlMsg)
connCtrlMsg.KickUserId = tokenVerifyRsp.PlayerID
connCtrlMsg.KickReason = kcp.EnetServerRelogin
k.messageQueue.SendToAll(&mq.NetMsg{
MsgType: mq.MsgTypeConnCtrl,
EventId: mq.KickPlayerNotify,
ConnCtrlMsg: connCtrlMsg,
})
// TODO 确保旧连接已下线 已通知GS已保存好数据
time.Sleep(time.Second)
} }
// 关联玩家uid和连接信息 // 关联玩家uid和连接信息
session.userId = tokenVerifyRsp.PlayerID session.userId = tokenVerifyRsp.PlayerID

View File

@@ -83,7 +83,7 @@ func (k *KcpConnectManager) Start() {
k.dispatchKey = regionEc2b.XorKey() k.dispatchKey = regionEc2b.XorKey()
// kcp // kcp
port := strconv.Itoa(int(config.CONF.Hk4e.KcpPort)) port := strconv.Itoa(int(config.CONF.Hk4e.KcpPort))
listener, err := kcp.ListenWithOptions(config.CONF.Hk4e.KcpAddr+":"+port, nil, 0, 0) listener, err := kcp.ListenWithOptions("0.0.0.0:"+port, nil, 0, 0)
if err != nil { if err != nil {
logger.Error("listen kcp err: %v", err) logger.Error("listen kcp err: %v", err)
return return

View File

@@ -43,6 +43,16 @@ func Run(ctx context.Context, configFile string) error {
return err return err
} }
APPID = rsp.GetAppId() APPID = rsp.GetAppId()
go func() {
ticker := time.NewTicker(time.Second * 15)
for {
<-ticker.C
_, _ = client.Discovery.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
ServerType: api.GS,
AppId: APPID,
})
}
}()
GSID = rsp.GetGsId() GSID = rsp.GetGsId()
defer func() { defer func() {
_, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{ _, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{

View File

@@ -263,6 +263,9 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
if worldAvatar == nil { if worldAvatar == nil {
continue continue
} }
if abilityMetaAddAbility.Ability == nil {
continue
}
worldAvatar.abilityList = append(worldAvatar.abilityList, abilityMetaAddAbility.Ability) worldAvatar.abilityList = append(worldAvatar.abilityList, abilityMetaAddAbility.Ability)
case proto.AbilityInvokeArgument_ABILITY_INVOKE_ARGUMENT_META_MODIFIER_CHANGE: case proto.AbilityInvokeArgument_ABILITY_INVOKE_ARGUMENT_META_MODIFIER_CHANGE:
abilityMetaModifierChange := new(proto.AbilityMetaModifierChange) abilityMetaModifierChange := new(proto.AbilityMetaModifierChange)

View File

@@ -174,6 +174,7 @@ func (u *UserManager) OfflineUser(player *model.Player, changeGsInfo *ChangeGsIn
logger.Error("deep copy player error: %v", err) logger.Error("deep copy player error: %v", err)
return return
} }
playerCopy.DbState = player.DbState
go func() { go func() {
u.SaveUserToDbSync(playerCopy) u.SaveUserToDbSync(playerCopy)
u.SaveUserToRedisSync(playerCopy) u.SaveUserToRedisSync(playerCopy)
@@ -342,6 +343,7 @@ func (u *UserManager) SaveTempOfflineUser(player *model.Player) {
logger.Error("deep copy player error: %v", err) logger.Error("deep copy player error: %v", err)
return return
} }
playerCopy.DbState = player.DbState
go func() { go func() {
u.SaveUserToDbSync(playerCopy) u.SaveUserToDbSync(playerCopy)
}() }()
@@ -384,10 +386,20 @@ func (u *UserManager) LoadUserFromDbSync(userId uint32) *model.Player {
} }
func (u *UserManager) SaveUserToDbSync(player *model.Player) { func (u *UserManager) SaveUserToDbSync(player *model.Player) {
err := u.dao.UpdatePlayer(player) if player.DbState == model.DbInsert {
if err != nil { err := u.dao.InsertPlayer(player)
logger.Error("update player error: %v", err) if err != nil {
return logger.Error("insert player error: %v", err)
return
}
} else if player.DbState == model.DbNormal {
err := u.dao.UpdatePlayer(player)
if err != nil {
logger.Error("update player error: %v", err)
return
}
} else {
logger.Error("invalid player db state: %v", player.DbState)
} }
} }

View File

@@ -32,7 +32,7 @@ type DiscoveryNATSRPCServer interface {
// 获取区服密钥信息 // 获取区服密钥信息
GetRegionEc2B(ctx context.Context, req *NullMsg) (*RegionEc2B, error) GetRegionEc2B(ctx context.Context, req *NullMsg) (*RegionEc2B, error)
// 获取负载最小的网关服务器的地址和端口 // 获取负载最小的网关服务器的地址和端口
GetGateServerAddr(ctx context.Context, req *NullMsg) (*GateServerAddr, error) GetGateServerAddr(ctx context.Context, req *GetGateServerAddrReq) (*GateServerAddr, error)
} }
// RegisterDiscoveryNATSRPCServer register Discovery service // RegisterDiscoveryNATSRPCServer register Discovery service
@@ -53,7 +53,7 @@ type DiscoveryNATSRPCClient interface {
// 获取区服密钥信息 // 获取区服密钥信息
GetRegionEc2B(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*RegionEc2B, error) GetRegionEc2B(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*RegionEc2B, error)
// 获取负载最小的网关服务器的地址和端口 // 获取负载最小的网关服务器的地址和端口
GetGateServerAddr(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*GateServerAddr, error) GetGateServerAddr(ctx context.Context, req *GetGateServerAddrReq, opt ...natsrpc.CallOption) (*GateServerAddr, error)
} }
type _DiscoveryNATSRPCClient struct { type _DiscoveryNATSRPCClient struct {
@@ -96,7 +96,7 @@ func (c *_DiscoveryNATSRPCClient) GetRegionEc2B(ctx context.Context, req *NullMs
err := c.c.Request(ctx, "GetRegionEc2B", req, rep, opt...) err := c.c.Request(ctx, "GetRegionEc2B", req, rep, opt...)
return rep, err return rep, err
} }
func (c *_DiscoveryNATSRPCClient) GetGateServerAddr(ctx context.Context, req *NullMsg, opt ...natsrpc.CallOption) (*GateServerAddr, error) { func (c *_DiscoveryNATSRPCClient) GetGateServerAddr(ctx context.Context, req *GetGateServerAddrReq, opt ...natsrpc.CallOption) (*GateServerAddr, error) {
rep := &GateServerAddr{} rep := &GateServerAddr{}
err := c.c.Request(ctx, "GetGateServerAddr", req, rep, opt...) err := c.c.Request(ctx, "GetGateServerAddr", req, rep, opt...)
return rep, err return rep, err

View File

@@ -159,6 +159,7 @@ type RegisterServerReq struct {
ServerType string `protobuf:"bytes,1,opt,name=server_type,json=serverType,proto3" json:"server_type,omitempty"` ServerType string `protobuf:"bytes,1,opt,name=server_type,json=serverType,proto3" json:"server_type,omitempty"`
GateServerAddr *GateServerAddr `protobuf:"bytes,2,opt,name=gate_server_addr,json=gateServerAddr,proto3" json:"gate_server_addr,omitempty"` GateServerAddr *GateServerAddr `protobuf:"bytes,2,opt,name=gate_server_addr,json=gateServerAddr,proto3" json:"gate_server_addr,omitempty"`
Version string `protobuf:"bytes,3,opt,name=version,proto3" json:"version,omitempty"`
} }
func (x *RegisterServerReq) Reset() { func (x *RegisterServerReq) Reset() {
@@ -207,6 +208,13 @@ func (x *RegisterServerReq) GetGateServerAddr() *GateServerAddr {
return nil return nil
} }
func (x *RegisterServerReq) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
type RegisterServerRsp struct { type RegisterServerRsp struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -372,6 +380,53 @@ func (x *KeepaliveServerReq) GetAppId() string {
return "" return ""
} }
type GetGateServerAddrReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
}
func (x *GetGateServerAddrReq) Reset() {
*x = GetGateServerAddrReq{}
if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetGateServerAddrReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetGateServerAddrReq) ProtoMessage() {}
func (x *GetGateServerAddrReq) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetGateServerAddrReq.ProtoReflect.Descriptor instead.
func (*GetGateServerAddrReq) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{7}
}
func (x *GetGateServerAddrReq) GetVersion() string {
if x != nil {
return x.Version
}
return ""
}
type RegionEc2B struct { type RegionEc2B struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -383,7 +438,7 @@ type RegionEc2B struct {
func (x *RegionEc2B) Reset() { func (x *RegionEc2B) Reset() {
*x = RegionEc2B{} *x = RegionEc2B{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[7] mi := &file_api_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -396,7 +451,7 @@ func (x *RegionEc2B) String() string {
func (*RegionEc2B) ProtoMessage() {} func (*RegionEc2B) ProtoMessage() {}
func (x *RegionEc2B) ProtoReflect() protoreflect.Message { func (x *RegionEc2B) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[7] mi := &file_api_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -409,7 +464,7 @@ func (x *RegionEc2B) ProtoReflect() protoreflect.Message {
// Deprecated: Use RegionEc2B.ProtoReflect.Descriptor instead. // Deprecated: Use RegionEc2B.ProtoReflect.Descriptor instead.
func (*RegionEc2B) Descriptor() ([]byte, []int) { func (*RegionEc2B) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{7} return file_api_proto_rawDescGZIP(), []int{8}
} }
func (x *RegionEc2B) GetData() []byte { func (x *RegionEc2B) GetData() []byte {
@@ -431,7 +486,7 @@ type GateServerAddr struct {
func (x *GateServerAddr) Reset() { func (x *GateServerAddr) Reset() {
*x = GateServerAddr{} *x = GateServerAddr{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_api_proto_msgTypes[8] mi := &file_api_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -444,7 +499,7 @@ func (x *GateServerAddr) String() string {
func (*GateServerAddr) ProtoMessage() {} func (*GateServerAddr) ProtoMessage() {}
func (x *GateServerAddr) ProtoReflect() protoreflect.Message { func (x *GateServerAddr) ProtoReflect() protoreflect.Message {
mi := &file_api_proto_msgTypes[8] mi := &file_api_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -457,7 +512,7 @@ func (x *GateServerAddr) ProtoReflect() protoreflect.Message {
// Deprecated: Use GateServerAddr.ProtoReflect.Descriptor instead. // Deprecated: Use GateServerAddr.ProtoReflect.Descriptor instead.
func (*GateServerAddr) Descriptor() ([]byte, []int) { func (*GateServerAddr) Descriptor() ([]byte, []int) {
return file_api_proto_rawDescGZIP(), []int{8} return file_api_proto_rawDescGZIP(), []int{9}
} }
func (x *GateServerAddr) GetIpAddr() string { func (x *GateServerAddr) GetIpAddr() string {
@@ -485,63 +540,68 @@ var file_api_proto_rawDesc = []byte{
0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x22, 0x2a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x22, 0x2a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x73, 0x70, 0x12, 0x15, 0x0a, 0x06, 0x61, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x73, 0x70, 0x12, 0x15, 0x0a, 0x06, 0x61,
0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70,
0x49, 0x64, 0x22, 0x78, 0x0a, 0x11, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x49, 0x64, 0x22, 0x92, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53,
0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76,
0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73,
0x72, 0x76, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x42, 0x0a, 0x10, 0x67, 0x61, 0x74, 0x65, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x42, 0x0a, 0x10, 0x67, 0x61, 0x74,
0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20,
0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x61, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47,
0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x52, 0x0e, 0x67, 0x61, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x52, 0x0e, 0x67,
0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x22, 0x3f, 0x0a, 0x11, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x18, 0x0a,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x73, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x70, 0x12, 0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3f, 0x0a, 0x11, 0x52, 0x65, 0x67, 0x69, 0x73,
0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x13, 0x0a, 0x05, 0x67, 0x73, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x15, 0x0a, 0x06,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x67, 0x73, 0x49, 0x64, 0x22, 0x49, 0x0a, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70,
0x0f, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x70, 0x49, 0x64, 0x12, 0x13, 0x0a, 0x05, 0x67, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x28, 0x0d, 0x52, 0x04, 0x67, 0x73, 0x49, 0x64, 0x22, 0x49, 0x0a, 0x0f, 0x43, 0x61, 0x6e, 0x63,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x0b, 0x73,
0x65, 0x12, 0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22, 0x4c, 0x0a, 0x12, 0x4b, 0x65, 0x65, 0x70, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x06,
0x61, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70,
0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x70, 0x49, 0x64, 0x22, 0x4c, 0x0a, 0x12, 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65,
0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x72,
0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22, 0x20, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x61, 0x70,
0x45, 0x63, 0x32, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49,
0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3d, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x65, 0x64, 0x22, 0x30, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76,
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x70, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72,
0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x70, 0x41, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73,
0x64, 0x64, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x69, 0x6f, 0x6e, 0x22, 0x20, 0x0a, 0x0a, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32,
0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x32, 0xad, 0x03, 0x0a, 0x09, 0x44, 0x69, 0x73, 0x63, 0x62, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x6f, 0x76, 0x65, 0x72, 0x79, 0x12, 0x4c, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3d, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72,
0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x70, 0x5f, 0x61, 0x64,
0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72,
0x72, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x32, 0xba, 0x03, 0x0a, 0x09, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65,
0x70, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x72, 0x79, 0x12, 0x4c, 0x0a, 0x0e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65,
0x76, 0x65, 0x72, 0x12, 0x19, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x61, 0x6e, 0x63, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65,
0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x71, 0x1a, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67,
0x67, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0f, 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x73, 0x70, 0x22, 0x00,
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x12, 0x3e, 0x0a, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
0x69, 0x2e, 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x12, 0x19, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x6e, 0x63,
0x72, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f,
0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x22, 0x00,
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x12, 0x44, 0x0a, 0x0f, 0x4b, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x65, 0x72,
0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4b,
0x41, 0x70, 0x70, 0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x65, 0x65, 0x70, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65,
0x71, 0x1a, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c,
0x6c, 0x4d, 0x73, 0x67, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e,
0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70,
0x49, 0x64, 0x52, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x52, 0x65, 0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69,
0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32, 0x62, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x70, 0x70, 0x49, 0x64, 0x52,
0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x1a, 0x14, 0x2e, 0x6e, 0x6f, 0x73, 0x70, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x52, 0x65, 0x67, 0x69, 0x6f,
0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32, 0x6e, 0x45, 0x63, 0x32, 0x62, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69,
0x62, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x1a, 0x14, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e,
0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x11, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x45, 0x63, 0x32, 0x62, 0x22, 0x00,
0x61, 0x70, 0x69, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x73, 0x67, 0x1a, 0x18, 0x2e, 0x6e, 0x6f, 0x12, 0x4f, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65,
0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1e, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69,
0x72, 0x41, 0x64, 0x64, 0x72, 0x22, 0x00, 0x42, 0x13, 0x5a, 0x11, 0x68, 0x6b, 0x34, 0x65, 0x2f, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64,
0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x64, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69,
0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x22,
0x00, 0x42, 0x13, 0x5a, 0x11, 0x68, 0x6b, 0x34, 0x65, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x61,
0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -556,32 +616,33 @@ func file_api_proto_rawDescGZIP() []byte {
return file_api_proto_rawDescData return file_api_proto_rawDescData
} }
var file_api_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_api_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_api_proto_goTypes = []interface{}{ var file_api_proto_goTypes = []interface{}{
(*NullMsg)(nil), // 0: node.api.NullMsg (*NullMsg)(nil), // 0: node.api.NullMsg
(*GetServerAppIdReq)(nil), // 1: node.api.GetServerAppIdReq (*GetServerAppIdReq)(nil), // 1: node.api.GetServerAppIdReq
(*GetServerAppIdRsp)(nil), // 2: node.api.GetServerAppIdRsp (*GetServerAppIdRsp)(nil), // 2: node.api.GetServerAppIdRsp
(*RegisterServerReq)(nil), // 3: node.api.RegisterServerReq (*RegisterServerReq)(nil), // 3: node.api.RegisterServerReq
(*RegisterServerRsp)(nil), // 4: node.api.RegisterServerRsp (*RegisterServerRsp)(nil), // 4: node.api.RegisterServerRsp
(*CancelServerReq)(nil), // 5: node.api.CancelServerReq (*CancelServerReq)(nil), // 5: node.api.CancelServerReq
(*KeepaliveServerReq)(nil), // 6: node.api.KeepaliveServerReq (*KeepaliveServerReq)(nil), // 6: node.api.KeepaliveServerReq
(*RegionEc2B)(nil), // 7: node.api.RegionEc2b (*GetGateServerAddrReq)(nil), // 7: node.api.GetGateServerAddrReq
(*GateServerAddr)(nil), // 8: node.api.GateServerAddr (*RegionEc2B)(nil), // 8: node.api.RegionEc2b
(*GateServerAddr)(nil), // 9: node.api.GateServerAddr
} }
var file_api_proto_depIdxs = []int32{ var file_api_proto_depIdxs = []int32{
8, // 0: node.api.RegisterServerReq.gate_server_addr:type_name -> node.api.GateServerAddr 9, // 0: node.api.RegisterServerReq.gate_server_addr:type_name -> node.api.GateServerAddr
3, // 1: node.api.Discovery.RegisterServer:input_type -> node.api.RegisterServerReq 3, // 1: node.api.Discovery.RegisterServer:input_type -> node.api.RegisterServerReq
5, // 2: node.api.Discovery.CancelServer:input_type -> node.api.CancelServerReq 5, // 2: node.api.Discovery.CancelServer:input_type -> node.api.CancelServerReq
6, // 3: node.api.Discovery.KeepaliveServer:input_type -> node.api.KeepaliveServerReq 6, // 3: node.api.Discovery.KeepaliveServer:input_type -> node.api.KeepaliveServerReq
1, // 4: node.api.Discovery.GetServerAppId:input_type -> node.api.GetServerAppIdReq 1, // 4: node.api.Discovery.GetServerAppId:input_type -> node.api.GetServerAppIdReq
0, // 5: node.api.Discovery.GetRegionEc2b:input_type -> node.api.NullMsg 0, // 5: node.api.Discovery.GetRegionEc2b:input_type -> node.api.NullMsg
0, // 6: node.api.Discovery.GetGateServerAddr:input_type -> node.api.NullMsg 7, // 6: node.api.Discovery.GetGateServerAddr:input_type -> node.api.GetGateServerAddrReq
4, // 7: node.api.Discovery.RegisterServer:output_type -> node.api.RegisterServerRsp 4, // 7: node.api.Discovery.RegisterServer:output_type -> node.api.RegisterServerRsp
0, // 8: node.api.Discovery.CancelServer:output_type -> node.api.NullMsg 0, // 8: node.api.Discovery.CancelServer:output_type -> node.api.NullMsg
0, // 9: node.api.Discovery.KeepaliveServer:output_type -> node.api.NullMsg 0, // 9: node.api.Discovery.KeepaliveServer:output_type -> node.api.NullMsg
2, // 10: node.api.Discovery.GetServerAppId:output_type -> node.api.GetServerAppIdRsp 2, // 10: node.api.Discovery.GetServerAppId:output_type -> node.api.GetServerAppIdRsp
7, // 11: node.api.Discovery.GetRegionEc2b:output_type -> node.api.RegionEc2b 8, // 11: node.api.Discovery.GetRegionEc2b:output_type -> node.api.RegionEc2b
8, // 12: node.api.Discovery.GetGateServerAddr:output_type -> node.api.GateServerAddr 9, // 12: node.api.Discovery.GetGateServerAddr:output_type -> node.api.GateServerAddr
7, // [7:13] is the sub-list for method output_type 7, // [7:13] is the sub-list for method output_type
1, // [1:7] is the sub-list for method input_type 1, // [1:7] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension type_name
@@ -680,7 +741,7 @@ func file_api_proto_init() {
} }
} }
file_api_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { file_api_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegionEc2B); i { switch v := v.(*GetGateServerAddrReq); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -692,6 +753,18 @@ func file_api_proto_init() {
} }
} }
file_api_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { file_api_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegionEc2B); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_api_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GateServerAddr); i { switch v := v.(*GateServerAddr); i {
case 0: case 0:
return &v.state return &v.state
@@ -710,7 +783,7 @@ func file_api_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_proto_rawDesc, RawDescriptor: file_api_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 9, NumMessages: 10,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@@ -16,7 +16,7 @@ service Discovery {
// 获取区服密钥信息 // 获取区服密钥信息
rpc GetRegionEc2b (NullMsg) returns (RegionEc2b) {} rpc GetRegionEc2b (NullMsg) returns (RegionEc2b) {}
// 获取负载最小的网关服务器的地址和端口 // 获取负载最小的网关服务器的地址和端口
rpc GetGateServerAddr (NullMsg) returns (GateServerAddr) {} rpc GetGateServerAddr (GetGateServerAddrReq) returns (GateServerAddr) {}
} }
message NullMsg { message NullMsg {
@@ -33,6 +33,7 @@ message GetServerAppIdRsp {
message RegisterServerReq { message RegisterServerReq {
string server_type = 1; string server_type = 1;
GateServerAddr gate_server_addr = 2; GateServerAddr gate_server_addr = 2;
string version = 3;
} }
message RegisterServerRsp { message RegisterServerRsp {
@@ -50,6 +51,10 @@ message KeepaliveServerReq {
string app_id = 2; string app_id = 2;
} }
message GetGateServerAddrReq {
string version = 1;
}
message RegionEc2b { message RegionEc2b {
bytes data = 1; bytes data = 1;
} }

View File

@@ -4,7 +4,9 @@ import (
"context" "context"
"sort" "sort"
"strings" "strings"
"sync"
"sync/atomic" "sync/atomic"
"time"
"hk4e/common/region" "hk4e/common/region"
"hk4e/node/api" "hk4e/node/api"
@@ -35,28 +37,29 @@ type ServerInstance struct {
appId string appId string
gateServerIpAddr string gateServerIpAddr string
gateServerPort uint32 gateServerPort uint32
version string
lastAliveTime int64
} }
type DiscoveryService struct { type DiscoveryService struct {
regionEc2b *random.Ec2b regionEc2b *random.Ec2b // 全局区服密钥信息
// TODO 加锁 serverInstanceMap map[string]*sync.Map // 全部服务器实例集合 key:服务器类型 value:服务器实例集合 -> key:appid value:服务器实例
serverInstanceMap map[string]map[string]*ServerInstance serverAppIdMap map[string]bool // 服务器appid集合 key:appid value:是否存在
serverAppIdMap map[string]bool gsIdCounter uint32 // GSID计数器
gsIdCounter uint32
} }
func NewDiscoveryService() *DiscoveryService { func NewDiscoveryService() *DiscoveryService {
r := new(DiscoveryService) r := new(DiscoveryService)
r.regionEc2b = region.NewRegionEc2b() r.regionEc2b = region.NewRegionEc2b()
logger.Info("region ec2b create ok, seed: %v", r.regionEc2b.Seed()) logger.Info("region ec2b create ok, seed: %v", r.regionEc2b.Seed())
r.serverInstanceMap = map[string]map[string]*ServerInstance{ r.serverInstanceMap = make(map[string]*sync.Map)
api.GATE: make(map[string]*ServerInstance), r.serverInstanceMap[api.GATE] = &sync.Map{}
api.GS: make(map[string]*ServerInstance), r.serverInstanceMap[api.GS] = &sync.Map{}
api.FIGHT: make(map[string]*ServerInstance), r.serverInstanceMap[api.FIGHT] = &sync.Map{}
api.PATHFINDING: make(map[string]*ServerInstance), r.serverInstanceMap[api.PATHFINDING] = &sync.Map{}
}
r.serverAppIdMap = make(map[string]bool) r.serverAppIdMap = make(map[string]bool)
r.gsIdCounter = 0 r.gsIdCounter = 0
go r.removeDeadServer()
return r return r
} }
@@ -84,8 +87,9 @@ func (s *DiscoveryService) RegisterServer(ctx context.Context, req *api.Register
logger.Info("register new gate server, ip: %v, port: %v", req.GateServerAddr.IpAddr, req.GateServerAddr.Port) logger.Info("register new gate server, ip: %v, port: %v", req.GateServerAddr.IpAddr, req.GateServerAddr.Port)
inst.gateServerIpAddr = req.GateServerAddr.IpAddr inst.gateServerIpAddr = req.GateServerAddr.IpAddr
inst.gateServerPort = req.GateServerAddr.Port inst.gateServerPort = req.GateServerAddr.Port
inst.version = req.Version
} }
instMap[appId] = inst instMap.Store(appId, inst)
logger.Info("new server appid is: %v", appId) logger.Info("new server appid is: %v", appId)
rsp := &api.RegisterServerRsp{ rsp := &api.RegisterServerRsp{
AppId: appId, AppId: appId,
@@ -103,11 +107,11 @@ func (s *DiscoveryService) CancelServer(ctx context.Context, req *api.CancelServ
if !exist { if !exist {
return nil, errors.New("server type not exist") return nil, errors.New("server type not exist")
} }
_, exist = instMap[req.AppId] _, exist = instMap.Load(req.AppId)
if !exist { if !exist {
return nil, errors.New("server not exist") return nil, errors.New("server not exist")
} }
delete(instMap, req.AppId) instMap.Delete(req.AppId)
return &api.NullMsg{}, nil return &api.NullMsg{}, nil
} }
@@ -117,12 +121,12 @@ func (s *DiscoveryService) KeepaliveServer(ctx context.Context, req *api.Keepali
if !exist { if !exist {
return nil, errors.New("server type not exist") return nil, errors.New("server type not exist")
} }
inst, exist := instMap[req.AppId] inst, exist := instMap.Load(req.AppId)
if !exist { if !exist {
return nil, errors.New("server not exist") return nil, errors.New("server not exist")
} }
// TODO serverInstance := inst.(*ServerInstance)
_ = inst serverInstance.lastAliveTime = time.Now().Unix()
return &api.NullMsg{}, nil return &api.NullMsg{}, nil
} }
@@ -133,7 +137,7 @@ func (s *DiscoveryService) GetServerAppId(ctx context.Context, req *api.GetServe
if !exist { if !exist {
return nil, errors.New("server type not exist") return nil, errors.New("server type not exist")
} }
if len(instMap) == 0 { if s.getServerInstanceMapLen(instMap) == 0 {
return nil, errors.New("no server found") return nil, errors.New("no server found")
} }
inst := s.getRandomServerInstance(instMap) inst := s.getRandomServerInstance(instMap)
@@ -152,16 +156,28 @@ func (s *DiscoveryService) GetRegionEc2B(ctx context.Context, req *api.NullMsg)
} }
// GetGateServerAddr 获取负载最小的网关服务器的地址和端口 // GetGateServerAddr 获取负载最小的网关服务器的地址和端口
func (s *DiscoveryService) GetGateServerAddr(ctx context.Context, req *api.NullMsg) (*api.GateServerAddr, error) { func (s *DiscoveryService) GetGateServerAddr(ctx context.Context, req *api.GetGateServerAddrReq) (*api.GateServerAddr, error) {
logger.Debug("get gate server addr") logger.Debug("get gate server addr")
instMap, exist := s.serverInstanceMap[api.GATE] instMap, exist := s.serverInstanceMap[api.GATE]
if !exist { if !exist {
return nil, errors.New("gate server not exist") return nil, errors.New("gate server not exist")
} }
if len(instMap) == 0 { if s.getServerInstanceMapLen(instMap) == 0 {
return nil, errors.New("no gate server found") return nil, errors.New("no gate server found")
} }
inst := s.getRandomServerInstance(instMap) versionInstMap := sync.Map{}
instMap.Range(func(key, value any) bool {
serverInstance := value.(*ServerInstance)
if serverInstance.version != req.Version {
return true
}
versionInstMap.Store(key, serverInstance)
return true
})
if s.getServerInstanceMapLen(&versionInstMap) == 0 {
return nil, errors.New("no gate server found")
}
inst := s.getRandomServerInstance(&versionInstMap)
logger.Debug("get gate server addr is, ip: %v, port: %v", inst.gateServerIpAddr, inst.gateServerPort) logger.Debug("get gate server addr is, ip: %v, port: %v", inst.gateServerIpAddr, inst.gateServerPort)
return &api.GateServerAddr{ return &api.GateServerAddr{
IpAddr: inst.gateServerIpAddr, IpAddr: inst.gateServerIpAddr,
@@ -169,13 +185,42 @@ func (s *DiscoveryService) GetGateServerAddr(ctx context.Context, req *api.NullM
}, nil }, nil
} }
func (s *DiscoveryService) getRandomServerInstance(instMap map[string]*ServerInstance) *ServerInstance { func (s *DiscoveryService) getRandomServerInstance(instMap *sync.Map) *ServerInstance {
instList := make(ServerInstanceSortList, 0) instList := make(ServerInstanceSortList, 0)
for _, v := range instMap { instMap.Range(func(key, value any) bool {
instList = append(instList, v) instList = append(instList, value.(*ServerInstance))
} return true
})
sort.Stable(instList) sort.Stable(instList)
index := random.GetRandomInt32(0, int32(len(instList)-1)) index := random.GetRandomInt32(0, int32(len(instList)-1))
inst := instList[index] inst := instList[index]
return inst return inst
} }
func (s *DiscoveryService) getServerInstanceMapLen(instMap *sync.Map) int {
count := 0
instMap.Range(func(key, value any) bool {
count++
return true
})
return count
}
// 定时移除掉线服务器
func (s *DiscoveryService) removeDeadServer() {
ticker := time.NewTicker(time.Second * 60)
for {
<-ticker.C
nowTime := time.Now().Unix()
for _, instMap := range s.serverInstanceMap {
instMap.Range(func(key, value any) bool {
serverInstance := value.(*ServerInstance)
if nowTime-serverInstance.lastAliveTime > 60 {
logger.Warn("remove dead server, server type: %v, appid: %v", serverInstance.serverType, serverInstance.appId)
instMap.Delete(key)
}
return true
})
}
}
}

View File

@@ -35,6 +35,16 @@ func Run(ctx context.Context, configFile string) error {
return err return err
} }
APPID = rsp.GetAppId() APPID = rsp.GetAppId()
go func() {
ticker := time.NewTicker(time.Second * 15)
for {
<-ticker.C
_, _ = client.Discovery.KeepaliveServer(context.TODO(), &api.KeepaliveServerReq{
ServerType: api.PATHFINDING,
AppId: APPID,
})
}
}()
defer func() { defer func() {
_, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{ _, _ = client.Discovery.CancelServer(context.TODO(), &api.CancelServerReq{
ServerType: api.PATHFINDING, ServerType: api.PATHFINDING,