Files
netease-modsdk-wiki/docs/mcdocs/2-Apollo/4-SDK/2-控制服事件.md
2025-03-18 14:46:12 +08:00

197 lines
5.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebarDepth: 1
---
# <span id="2-控制服事件"></span>2-控制服事件
事件的定义。
<span id="服务器"></span>
## 服务器
<span id="ResetGamesBeginEvent"></span>
### ResetGamesBeginEvent
- 描述
开始重置lobby/game事件。具体可以参见API【ResetServer】
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
- 返回值
<span id="ResetGamesEndEvent"></span>
### ResetGamesEndEvent
- 描述
重置lobby/game结束事件。本事件只是表示重置完成了但是服务器可能还未完成初始化。具体可以参见API【ResetServer】
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
| bSuccess | bool | 重置是否成功。true表示重置成功否则表示失败 |
- 返回值
<span id="RollingCloseServersEndEvent"></span>
### RollingCloseServersEndEvent
- 描述
使用RollingCloseServersEndEvent滚动关服结束事件。
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| request | str | 滚动关服的请求参数为json格式字符串包含以下属性serverlistserverIdsapolloidapollo_key |
| response | str | 滚动关服的返回参数为json格式字符串包含以下属性code错误码message错误信息entity移除的服务器信息其中字段与RollingUpdateServersEndEvent相同 |
| suc | bool | 滚动关服是否成功 |
- 返回值
<span id="RollingUpdateServersEndEvent"></span>
### RollingUpdateServersEndEvent
- 描述
使用RollingUpdateServers滚动更新服务器结束事件。
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| request | str | 滚动更新的请求参数为json格式字符串包含以下属性app_versionipserver_typeadd_numapolloidapollo_key |
| response | str | 滚动更新的返回参数为json格式字符串包含以下属性code错误码message错误信息entity新增或移除的服务器信息 |
| suc | bool | 滚动更新是否成功 |
- 返回值
- 备注
entity为一个list(dict)每个元素包含以下字段对应mcstudio的服务器配置
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| serverid | int | 服务器id |
| ip | str | 服务器ip |
| mods | str | 服务器mod列表 |
| app_type | str | game/lobby/proxy |
| type | str | 服务器类型 |
| save | bool | 是否保存地图 |
| save_id | int | 使用地图 |
| gb | int | 单进程内存 |
<span id="ServerConnectedEvent"></span>
### ServerConnectedEvent
- 描述
lobby/game/proxy成功建立连接时触发
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
| protocolVersion | int | 协议版本号 |
- 返回值
<span id="ServerDisconnectEvent"></span>
### ServerDisconnectEvent
- 描述
lobby/game/proxy断开连接时触发
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
- 返回值
<span id="配置"></span>
## 配置
<span id="NetGameCommonConfChangeEvent"></span>
### NetGameCommonConfChangeEvent
- 描述
公共配置发生变化时触发,具体包括:新增或删服服务器;服务器相关配置变化;日志等级发生变化
- 返回值
<span id="玩家"></span>
## 玩家
<span id="PlayerLoginServerEvent"></span>
### PlayerLoginServerEvent
- 描述
玩家开始登陆事件此时master开始给玩家分配lobby/game可以区分玩家是登录还是切服
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 客户端即将登录的服务器id |
| uid | int/long | 玩家的uid |
| protocolVersion | int | 协议版本号 |
| isTransfer | bool | True: 切服False登录 |
| isReconnect | bool | True: 断线重连False正常登录 |
| isPeUser | bool | True: 玩家从手机端登录False玩家从PC端登录 |
- 返回值
<span id="PlayerLogoutServerEvent"></span>
### PlayerLogoutServerEvent
- 描述
玩家登出时触发玩家在lobby/game下载行为包的过程中退出也会触发该事件可以以区分玩家是登出还是切服
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 客户端连接的proxy服务器id |
| uid | int/long | 玩家的uid |
| isTransfer | bool | True: 切服False登出 |
- 返回值
<span id="PlayerTransferServerEvent"></span>
### PlayerTransferServerEvent
- 描述
玩家开始切服事件此时master开始为玩家准备服务器玩家还没切服完毕后续可能切服失败
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 客户端连接的proxy服务器id |
| uid | int/long | 玩家的uid |
| targetServerId | int | 目标lobby/game服务器id |
| targetServerType | str | 目标服务器类型,比如"game"或"lobby"。若targetServerId为0则会从目标类型的多个服务器中随机选一个作为目标服务器 |
| protocolVersion | int | 协议版本号 |
| transferParam | str | 切服参数。调用【TransferToOtherServer】或【TransferToOtherServerById】传入的切服参数。 |
- 返回值