更新文档

This commit is contained in:
flswld
2023-01-31 00:10:18 +08:00
parent 5a175722d7
commit bd8a68b8d6
12 changed files with 56 additions and 42 deletions

View File

@@ -11,6 +11,7 @@ clean:
rm -rf ./bin rm -rf ./bin
rm -rf ./protocol/proto rm -rf ./protocol/proto
rm -rf ./gate/client_proto/client_proto_gen.go rm -rf ./gate/client_proto/client_proto_gen.go
rm -rf ./gs/api/*.pb.go && rm -rf ./node/api/*.pb.go
# 构建服务器二进制文件 # 构建服务器二进制文件
.PHONY: build .PHONY: build
@@ -20,13 +21,13 @@ build:
# 清理镜像 # 清理镜像
.PHONY: docker_clean .PHONY: docker_clean
docker_clean: docker_clean:
rm -rf ./docker/node/bin/* rm -rf ./docker/node/bin/node
rm -rf ./docker/dispatch/bin/* rm -rf ./docker/dispatch/bin/dispatch
rm -rf ./docker/gate/bin/* rm -rf ./docker/gate/bin/gate
rm -rf ./docker/fight/bin/* rm -rf ./docker/fight/bin/fight
rm -rf ./docker/pathfinding/bin/* rm -rf ./docker/pathfinding/bin/pathfinding
rm -rf ./docker/gs/bin/* rm -rf ./docker/gs/bin/gs
rm -rf ./docker/gm/bin/* rm -rf ./docker/gm/bin/gm
docker rmi flswld/node:$(VERSION) docker rmi flswld/node:$(VERSION)
docker rmi flswld/dispatch:$(VERSION) docker rmi flswld/dispatch:$(VERSION)
docker rmi flswld/gate:$(VERSION) docker rmi flswld/gate:$(VERSION)
@@ -35,16 +36,27 @@ docker_clean:
docker rmi flswld/gs:$(VERSION) docker rmi flswld/gs:$(VERSION)
docker rmi flswld/gm:$(VERSION) docker rmi flswld/gm:$(VERSION)
# 复制配置模板等文件
.PHONY: docker_config
docker_config:
mkdir -p ./docker/node/bin && cp -rf ./cmd/node/* ./docker/node/bin/
mkdir -p ./docker/dispatch/bin && cp -rf ./cmd/dispatch/* ./docker/dispatch/bin/
mkdir -p ./docker/gate/bin && cp -rf ./cmd/gate/* ./docker/gate/bin/
mkdir -p ./docker/fight/bin && cp -rf ./cmd/fight/* ./docker/fight/bin/
mkdir -p ./docker/pathfinding/bin && cp -rf ./cmd/pathfinding/* ./docker/pathfinding/bin/
mkdir -p ./docker/gs/bin && cp -rf ./cmd/gs/* ./docker/gs/bin/
mkdir -p ./docker/gm/bin && cp -rf ./cmd/gm/* ./docker/gm/bin/
# 构建镜像 # 构建镜像
.PHONY: docker_build .PHONY: docker_build
docker_build: docker_build:
mkdir -p ./docker/node/bin && cp -rf ./bin/node ./cmd/node/* ./docker/node/bin/ mkdir -p ./docker/node/bin && cp -rf ./bin/node ./docker/node/bin/
mkdir -p ./docker/dispatch/bin && cp -rf ./bin/dispatch ./cmd/dispatch/* ./docker/dispatch/bin/ mkdir -p ./docker/dispatch/bin && cp -rf ./bin/dispatch ./docker/dispatch/bin/
mkdir -p ./docker/gate/bin && cp -rf ./bin/gate ./cmd/gate/* ./docker/gate/bin/ mkdir -p ./docker/gate/bin && cp -rf ./bin/gate ./docker/gate/bin/
mkdir -p ./docker/fight/bin && cp -rf ./bin/fight ./cmd/fight/* ./docker/fight/bin/ mkdir -p ./docker/fight/bin && cp -rf ./bin/fight ./docker/fight/bin/
mkdir -p ./docker/pathfinding/bin && cp -rf ./bin/pathfinding ./cmd/pathfinding/* ./docker/pathfinding/bin/ mkdir -p ./docker/pathfinding/bin && cp -rf ./bin/pathfinding ./docker/pathfinding/bin/
mkdir -p ./docker/gs/bin && cp -rf ./bin/gs ./cmd/gs/* ./docker/gs/bin/ mkdir -p ./docker/gs/bin && cp -rf ./bin/gs ./docker/gs/bin/
mkdir -p ./docker/gm/bin && cp -rf ./bin/gm ./cmd/gm/* ./docker/gm/bin/ mkdir -p ./docker/gm/bin && cp -rf ./bin/gm ./docker/gm/bin/
docker build -t flswld/node:$(VERSION) ./docker/node docker build -t flswld/node:$(VERSION) ./docker/node
docker build -t flswld/dispatch:$(VERSION) ./docker/dispatch docker build -t flswld/dispatch:$(VERSION) ./docker/dispatch
docker build -t flswld/gate:$(VERSION) ./docker/gate docker build -t flswld/gate:$(VERSION) ./docker/gate

View File

@@ -41,8 +41,9 @@ make gen_client_proto # 生成客户端协议代理(非必要 详见gate/client_
* 构建 * 构建
```shell ```shell
make build # 构建服务器二进制文件 make build # 构建服务器二进制文件
make docker_build # 构建镜像 make docker_config # 复制配置模板等文件
make docker_build # 构建镜像
``` ```
* 启动 * 启动
@@ -80,5 +81,6 @@ GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore
## 代码提交规范 ## 代码提交规范
* 提交前**必须**进行go fmt(GoLand可在commit窗口的设置里勾选默认是启用的) * 提交前**必须**进行go fmt(GoLand可在commit窗口的设置里勾选默认是启用的)
* 进行全局格式化时请跳过gdconf目录这是配置表数据包含大量的json、lua、txt等文件
* 单行注释的注释符与注释内容之间需要加一个空格(GoLand可在设置Editor/CodeStyle/Go/Other里打开) * 单行注释的注释符与注释内容之间需要加一个空格(GoLand可在设置Editor/CodeStyle/Go/Other里打开)
* 导入包时需要将标准库、本地包、第三方包用空行分开(GoLand可在设置Editor/CodeStyle/Go/Imports里打开) * 导入包时需要将标准库、本地包、第三方包用空行分开(GoLand可在设置Editor/CodeStyle/Go/Imports里打开)

View File

@@ -2,7 +2,7 @@
kcp_addr = "127.0.0.1" # 该地址只用来注册到节点服务器 填网关的外网地址 网关本地监听为0.0.0.0 kcp_addr = "127.0.0.1" # 该地址只用来注册到节点服务器 填网关的外网地址 网关本地监听为0.0.0.0
kcp_port = 22222 kcp_port = 22222
client_proto_proxy_enable = false client_proto_proxy_enable = false
version = "320" version = "300,310,320" # 支持的客户端协议版本号 三位数字 多个以逗号分隔 如300,310,320
gate_tcp_mq_addr = "127.0.0.1" # 访问网关tcp直连消息队列的地址 填网关的内网地址 gate_tcp_mq_addr = "127.0.0.1" # 访问网关tcp直连消息队列的地址 填网关的内网地址
gate_tcp_mq_port = 33333 gate_tcp_mq_port = 33333
login_sdk_url = "http://127.0.0.1:8080/gate/token/verify" # 网关登录验证token的sdk服务器地址 目前填dispatch的内网地址 login_sdk_url = "http://127.0.0.1:8080/gate/token/verify" # 网关登录验证token的sdk服务器地址 目前填dispatch的内网地址

View File

@@ -43,10 +43,10 @@ type Hk4e struct {
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"` Version string `toml:"version"` // 支持的客户端协议版本号 三位数字 多个以逗号分隔 如300,310,320
GateTcpMqAddr string `toml:"gate_tcp_mq_addr"` // 访问网关tcp直连消息队列的地址 填网关的内网地址 GateTcpMqAddr string `toml:"gate_tcp_mq_addr"` // 访问网关tcp直连消息队列的地址 填网关的内网地址
GateTcpMqPort int32 `toml:"gate_tcp_mq_port"` GateTcpMqPort int32 `toml:"gate_tcp_mq_port"`
LoginSdkUrl string `toml:"login_sdk_url"` LoginSdkUrl string `toml:"login_sdk_url"` // 网关登录验证token的sdk服务器地址 目前填dispatch的内网地址
} }
// MQ 消息队列 // MQ 消息队列

View File

@@ -56,7 +56,6 @@ services:
- /usr/share/zoneinfo:/usr/share/zoneinfo - /usr/share/zoneinfo:/usr/share/zoneinfo
- ./docker/gate/bin/application.toml:/gate/application.toml - ./docker/gate/bin/application.toml:/gate/application.toml
- ./docker/gate/bin/key:/gate/key - ./docker/gate/bin/key:/gate/key
- ./gate/client_proto/proto/client_cmd.csv:/gate/client_cmd.csv
depends_on: depends_on:
- dispatch_services - dispatch_services
deploy: deploy:
@@ -76,7 +75,6 @@ services:
- /etc/timezone:/etc/timezone - /etc/timezone:/etc/timezone
- /usr/share/zoneinfo:/usr/share/zoneinfo - /usr/share/zoneinfo:/usr/share/zoneinfo
- ./docker/fight/bin/application.toml:/fight/application.toml - ./docker/fight/bin/application.toml:/fight/application.toml
- ./gate/client_proto/proto/client_cmd.csv:/fight/client_cmd.csv
depends_on: depends_on:
- gate_services - gate_services
deploy: deploy:
@@ -116,7 +114,6 @@ services:
- /usr/share/zoneinfo:/usr/share/zoneinfo - /usr/share/zoneinfo:/usr/share/zoneinfo
- ./docker/gs/bin/application.toml:/gs/application.toml - ./docker/gs/bin/application.toml:/gs/application.toml
- ./gdconf/game_data_config:/gs/game_data_config - ./gdconf/game_data_config:/gs/game_data_config
- ./gate/client_proto/proto/client_cmd.csv:/gs/client_cmd.csv
depends_on: depends_on:
- pathfinding_services - pathfinding_services
deploy: deploy:

View File

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

View File

@@ -5,6 +5,7 @@ import (
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"strings"
"syscall" "syscall"
"time" "time"
@@ -36,7 +37,7 @@ func Run(ctx context.Context, configFile string) error {
MqAddr: config.CONF.Hk4e.GateTcpMqAddr, MqAddr: config.CONF.Hk4e.GateTcpMqAddr,
MqPort: uint32(config.CONF.Hk4e.GateTcpMqPort), MqPort: uint32(config.CONF.Hk4e.GateTcpMqPort),
}, },
Version: config.CONF.Hk4e.Version, Version: strings.Split(config.CONF.Hk4e.Version, ","),
}) })
if err != nil { if err != nil {
return err return err

View File

@@ -7,7 +7,7 @@
## 使用方法 ## 使用方法
> 1. 在此目录下建立proto目录 > 1. 在此目录下建立proto目录
> 2. 将对应版本的proto协议文件复制到proto目录下并编译成pb.go > 2. 将对应版本的proto协议文件和client_cmd.csv协议号文件复制到proto目录下
> 3. make gen_client_proto > 3. 到项目根目录下执行`make gen_client_proto`(本操作可能会修改proto文件请注意备份)
> 4. 将client_cmd.csv放入gate和gs和fight服务器的运行目录下 > 4. 执行`protoc --go_out=. *.proto`将proto目录下的proto协议文件编译成pb.go
> 5. 将gate和gs和fight服务器的配置文件中开启client_proto_proxy_enable客户端协议代理功能 > 5. 将gate和gs和fight服务器的配置文件中开启client_proto_proxy_enable客户端协议代理功能

View File

@@ -12,11 +12,11 @@ service GM {
} }
message CmdRequest { message CmdRequest {
string func_name = 1; string func_name = 1;
repeated string param = 2; repeated string param = 2;
} }
message CmdReply { message CmdReply {
int32 code = 1; // 0 表示成功 int32 code = 1; // 0 表示成功
string message = 2; string message = 2;
} }

View File

@@ -35,24 +35,24 @@ 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; repeated string version = 3;
} }
message RegisterServerRsp { message RegisterServerRsp {
string app_id = 1; string app_id = 1;
uint32 gs_id = 2; uint32 gs_id = 2;
} }
message CancelServerReq { message CancelServerReq {
string server_type = 1; string server_type = 1;
string app_id = 2; string app_id = 2;
} }
message KeepaliveServerReq { message KeepaliveServerReq {
string server_type = 1; string server_type = 1;
string app_id = 2; string app_id = 2;
} }
message GetGateServerAddrReq { message GetGateServerAddrReq {
@@ -70,12 +70,12 @@ message RegionEc2b {
message GateServerAddr { message GateServerAddr {
string kcp_addr = 1; string kcp_addr = 1;
uint32 kcp_port = 2; uint32 kcp_port = 2;
string mq_addr = 3; string mq_addr = 3;
uint32 mq_port = 4; uint32 mq_port = 4;
} }
message GateServerInfo { message GateServerInfo {
string app_id = 1; string app_id = 1;
string mq_addr = 2; string mq_addr = 2;
uint32 mq_port = 3; uint32 mq_port = 3;
} }

View File

@@ -43,7 +43,7 @@ type ServerInstance struct {
gateServerKcpPort uint32 gateServerKcpPort uint32
gateServerMqAddr string gateServerMqAddr string
gateServerMqPort uint32 gateServerMqPort uint32
version string version []string
lastAliveTime int64 lastAliveTime int64
gsId uint32 gsId uint32
} }
@@ -186,10 +186,12 @@ func (s *DiscoveryService) GetGateServerAddr(ctx context.Context, req *api.GetGa
versionInstMap := sync.Map{} versionInstMap := sync.Map{}
instMap.Range(func(key, value any) bool { instMap.Range(func(key, value any) bool {
serverInstance := value.(*ServerInstance) serverInstance := value.(*ServerInstance)
if serverInstance.version != req.Version { for _, version := range serverInstance.version {
return true if version == req.Version {
versionInstMap.Store(key, serverInstance)
return true
}
} }
versionInstMap.Store(key, serverInstance)
return true return true
}) })
if s.getServerInstanceMapLen(&versionInstMap) == 0 { if s.getServerInstanceMapLen(&versionInstMap) == 0 {