This commit is contained in:
MrOkiDoki 2023-08-17 18:39:23 +03:00
commit 7f8ee714cb
4 changed files with 49 additions and 11 deletions

26
.github/workflows/dotnet.yml vendored Normal file
View File

@ -0,0 +1,26 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET build
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore

View File

@ -28,8 +28,12 @@ Language [English](/README.md) | [中文](/README-zhCN.md) | 한국어
이 프로젝트는 CMD에서 [`dotnet build`](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build)를 사용하거나 선호하는 IDE에서 Run / Build 옵션을 이용하여 빌드할 수 있습니다.
또는, Docker를 사용할 수 있습니다. 이를 사용하는 쉬운 방법은 `docker compose up`을 실행하는 것입니다.
### Connecting to the gameserver
API를 작성하고 컴파일한 후, 다른 곳에서 호스팅하고 싶을 수도 있습니다. 게임 서버가 실행되는 서버와 동일한 서버일 수 있으며 완전히 다른 서버일 수도 있습니다. 보다 원활하고 빠른 통신을 위해 게임 서버와의 지연 시간을 최소화하는 것이 좋습니다. 동일한 `ServerListener`를 동시에 *여러* 게임 서버에 사용할 수 있습니다. 게임 서버의 실행 옵션에서 API 서버(주소와 포트)를 지정할 수 있습니다.
게임 서버는 실행 인수 `-apiendpoint=<IP>:<PORT>`를 사용하여 API에 연결합니다. 여기서 <PORT>는 리스터가 수신하는 포트이고, IP는 API 서버의 IP입니다.
게임 서버는 실행 인수 `-apiendpoint=<IP>:<PORT>`를 사용하여 API에 연결합니다. 여기서 <PORT>는 리스터가 수신하는 포트이고, IP는 API 서버의 IP입니다.
현재 프로젝트의 API는 `29294` 포트에서 수신 대기하도록 구성되어 있습니다. 이를 변경하려면 `listener.start(port)`에서 변경해야 합니다. `29294` 포트는 Docker에 노출되며 Docker Compose에서 호스트의 동일한 포트에 바인딩됩니다. 즉, Docker를 사용할 때 `Dockerfile``docker-compose.yml` (Compose를 사용할 때)에서도 포트를 변경해야 합니다. [EXPOSE 문서](https://docs.docker.com/engine/reference/builder/#expose) 와 [NETWORKING 문서](https://docs.docker.com/compose/networking/)를 참고하세요.

View File

@ -1,11 +1,11 @@
# BattleBit Remastered 服务 API
# BattleBit Remastered 服务 API
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Language [English](/README.md) | 中文 | [한국어](/README_koKR.md)
Language [English](/README.md) | 中文 | [한국어](/README-koKR.md)
这个 repo 是 BBR像素战地的服务端 API
BBR像素战地的服务端 API 在部署后可以提供`社区服`所需要的游戏服务端事件处理以及事件控制。
## 如何开始
@ -15,19 +15,23 @@ Language [English](/README.md) | 中文 | [한국어](/README_koKR.md)
- 可以写基于 [.NET 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) 的 C# 代码。
- 可以在生产环境中部署此代码。
### 如何制作功能
### 制作功能
制作对应的功能可以 [查看维基(制作中)](https://github.com/MrOkiDoki/BattleBit-Community-Server-API/wiki).
使用这个 API 将在运行本程序后开启一个`ServerListener` 的监听进程,传递你*自己定义*的`Player` 和 `GameServer` 类型覆盖原本游戏自身的`Player` 和 `GameServer`类型。在这些类型中添加任何你想要的功能,以此来定制属于你自己的游戏玩法。
如果想给你的服务端添加功能,可以直接把覆盖的功能写在 `Program.cs``MyPlayer``MyGameServer`中,当然也可以按照框架规范进行其他的功能纂写。
本 API 将在运行后开启一个`ServerListener` 的监听进程,传递你 *自己定义*`Player``GameServer` 类型覆盖原本游戏自身的 `Player``GameServer` 类型。在这些类型中添加任何你想要的功能,以此来定制属于你自己的游戏玩法。
如果想给你的游戏服务端添加功能,可以直接把覆盖的功能写入 `Program.cs``MyPlayer``MyGameServer`中,当然你也可以按照框架规范进行其他的功能纂写。
### 编译
可以直接使用 [`dotnet build`](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build) 的命令进行编译,或者在你的 IDE 中自定义编译.
可以直接使用 [`dotnet build`](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build) 的命令进行编译,或者在你的 IDE 中自定义编译
### 连接服务端
### 连接游戏服务端
当你将此项目的功能写完并进行了编译后,需要将此 API 服务进行部署。此 API 服务可以部署在本地网络、本机网络或者广域网中。我们强烈建议以「最低延迟」为基准进行部署,以保证 `ServerListener` 可以同时监听 *多个* 游戏服务端。
你可以在游戏服务端的启动配置中对 API 的地址和端口进行设定。
游戏服务端通过启动参数 `"-apiEndpoint=<IP>:<端口>"` 来与本 API 实例进行通信, 启动参数中的 `<端口>` 指的是本 API 服务中指定的端口 `<IP>` 指的是本 API 服务部署实例的 IP 地址。
如果游戏服务端实例与本 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/)。

View File

@ -2,7 +2,7 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Language English | [中文](/README-zhCN.md) | [한국어](/README_koKR.md)
Language English | [中文](/README-zhCN.md) | [한국어](/README-koKR.md)
This repository provides an API that can be used to handle events on your community server(s) and manipulate them.
@ -26,8 +26,12 @@ The easiest way to get started with all of this, is to use `Program.cs` and add
This project can either be built by using [`dotnet build`](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build) on the command-line or by using the run / build options inside your preferred IDE.
Alternatively, you can use Docker to run it. An easy way to do this it to run `docker compose up`.
### Connecting to the gameserver(s)
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.
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.
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/).