---
sidebarDepth: 1
---
# 2-控制服事件
事件的定义。
## 服务器
### ResetGamesBeginEvent
- 描述
开始重置lobby/game事件。具体可以参见API【ResetServer】
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
- 返回值
无
### ResetGamesEndEvent
- 描述
重置lobby/game结束事件。本事件只是表示重置完成了,但是服务器可能还未完成初始化。具体可以参见API【ResetServer】
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
| bSuccess | bool | 重置是否成功。true表示重置成功,否则表示失败 |
- 返回值
无
### RollingCloseServersEndEvent
- 描述
使用RollingCloseServersEndEvent滚动关服结束事件。
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| request | str | 滚动关服的请求参数,为json格式字符串,包含以下属性:serverlist,serverIds,apolloid,apollo_key |
| response | str | 滚动关服的返回参数,为json格式字符串,包含以下属性:code错误码,message错误信息,entity移除的服务器信息,其中字段与RollingUpdateServersEndEvent相同 |
| suc | bool | 滚动关服是否成功 |
- 返回值
无
### RollingUpdateServersEndEvent
- 描述
使用RollingUpdateServers滚动更新服务器结束事件。
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| request | str | 滚动更新的请求参数,为json格式字符串,包含以下属性:app_version,ip,server_type,add_num,apolloid,apollo_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 | 单进程内存 |
### ServerConnectedEvent
- 描述
lobby/game/proxy成功建立连接时触发
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
| protocolVersion | int | 协议版本号 |
- 返回值
无
### ServerDisconnectEvent
- 描述
lobby/game/proxy断开连接时触发
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 服务器id |
- 返回值
无
## 配置
### NetGameCommonConfChangeEvent
- 描述
公共配置发生变化时触发,具体包括:新增或删服服务器;服务器相关配置变化;日志等级发生变化
- 返回值
无
## 玩家
### 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端登录 |
- 返回值
无
### PlayerLogoutServerEvent
- 描述
玩家登出时触发,玩家在lobby/game下载行为包的过程中退出也会触发该事件,可以以区分玩家是登出还是切服
- 参数
| 参数名 | 数据类型 | 说明 |
| :--- | :--- | :--- |
| serverId | int | 客户端连接的proxy服务器id |
| uid | int/long | 玩家的uid |
| isTransfer | bool | True: 切服,False:登出 |
- 返回值
无
### 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】传入的切服参数。 |
- 返回值
无