Merge pull request #42 from Ra2Com/main

Add apiToken declaration thing to adapt Oki's latest new stuff
This commit is contained in:
Julgers 2023-08-18 08:01:34 +02:00 committed by GitHub
commit 4f0ce62f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,3 @@
# BattleBit Remastered 服务端 API
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@ -29,9 +28,17 @@ BBR像素战地的服务端 API 在部署后可以提供`社区服`所需
### 连接游戏服务端
当你将此项目的功能写完并进行了编译后,需要将此 API 服务进行部署。此 API 服务可以部署在本地网络、本机网络或者广域网中。我们强烈建议以「最低延迟」为基准进行部署,以保证 `ServerListener` 可以同时监听 *多个* 游戏服务端。
你可以在游戏服务端的启动配置中对 API 的地址和端口进行设定。
#### 启动参数
游戏服务端通过启动参数 `"-apiEndpoint=<IP>:<端口>"` 来与本 API 实例进行通信, 启动参数中的 `<端口>` 指的是本 API 服务中指定的端口 `<IP>` 指的是本 API 服务部署实例的 IP 地址。
如果你在 API 服务中定义游戏服务端连接 API 服务时需要进行 `Api Token` 的验证,那么在游戏服务端的启动参数中需要增加 `"-apiToken=<你在程序中设置的 ApiToken>"`,当游戏服务端启动项的`Api Token`与 API 服务中`Api Token`的一致时,游戏服务端才可以与指定的 API 服务进行通信。
在游戏服务端的运行时,你也可以通过在命令行中输入 `setapitoken <新的token>` 来直接修改运行中的服务端的 `Api Token`
#### 调整 API 端口
如果游戏服务端实例与本 API 实例不在同一个实例上进行部署,且你想修改本 API 实例的端口 `29294`,你可以查看 `Progran.cs``listener.Start(29294);` 并把 `29294` 修改为你想指定或防火墙等安全策略已通过的端口号。
如果你的实例运行在 Docker 容器中,端口 `29294` (或你修改的其他端口)也同时需要在 Docker 容器配置中进行修改并对外暴露。也就是说你需要修改 `Dockerfile` 且(如果有使用到容器集群编排)还有需要修改 `docker-compose.yml` 。相关参考资料可以查看 Docker 官方文档 [EXPOSE in the Dockerfile reference](https://docs.docker.com/engine/reference/builder/#expose) 以及 [networking in Compose](https://docs.docker.com/compose/networking/)。
如果你的实例运行在 Docker 容器中,端口 `29294` (或你修改的其他端口)也同时需要在 Docker 容器配置中进行修改并对外暴露。也就是说你需要修改 `Dockerfile` 且(如果有使用到容器集群编排)还有可能需要修改 `docker-compose.yml` 。相关参考资料可以查看 Docker 官方文档 [EXPOSE in the Dockerfile reference](https://docs.docker.com/engine/reference/builder/#expose) 以及 [networking in Compose](https://docs.docker.com/compose/networking/)。

View File

@ -32,6 +32,14 @@ Alternatively, you can use Docker to run it. An easy way to do this it to run `d
After writing and compiling this project. You will want to host it somewhere. This could be on the same server that the gameservers run on, or somewhere completely different. We do recommend to keep the latency to the gameserver minimal for smoother and faster communication. The same `ServerListener` can be used for *multiple* gameservers at the same time. You can specify the API server (address & port) in the launch options of the gameserver.
#### Gameserver start arguments
The gameserver connects to the API with the launch argument `"-apiendpoint=<IP>:<port>"`, where `<port>` is the port that the listener listens on and the `<IP>` is the IP of the API server.
If `Api Token` verification is required in your Server API, you need to add `"-apiToken=<ApiToken>"` to the startup parameters of the gameserver(s). Should `<ApiToken>` the same as `Api Token` defined in Server API, gameserver(s) can communicate with Server API.
When the gameserver is up, you can also directly modify the `Api Token` of the gameserver by entering `setapitoken <new token>` in its command line.
#### Adjust API listening port
The project is currently configured to have the API listen on port `29294`. If you want to change this, make sure to change it in the code (on your `listener.start(port)`). Port `29294` is also exposed in Docker and bound to the same port on the host in Docker Compose. This means that when using Docker, you will have to change the port in the `Dockerfile` and in `docker-compose.yml` (when using Compose) as well. See [EXPOSE in the Dockerfile reference](https://docs.docker.com/engine/reference/builder/#expose) and [networking in Compose](https://docs.docker.com/compose/networking/).