### Start Server Components with PyCluster
Source: https://www.kbelab.com/advance/debug/pycluster.html
Initiate server components using the 'start' command followed by the component name. Supported components include dbmgr, baseappmgr, cellappmgr, baseapp, cellapp, and loginapp. Ensure the KBE_ROOT environment variable is set.
```bash
[kbe@gameserver ~]$
python $KBE_ROOT/kbe/tools/server/pycluster/cluster_controller.py start dbmgr|baseappmgr|cellappmgr|baseapp|cellapp|cellapp|loginapp
```
--------------------------------
### KBEngine Resource Path Example
Source: https://www.kbelab.com/basic/structure.html
Example of using KBEngine's API to map a space geometry. This demonstrates how relative paths are resolved within the res folder.
```python
res_path = "spaces/xinshoucun"
KBEngine.addSpaceGeometryMapping(self.spaceID, None, res_path)
# 会读取该文件夹下的`spaces/xinshoucun`下的数据,来关联某空间的几何数据映射。
```
--------------------------------
### Entity Declaration Example
Source: https://www.kbelab.com/basic/structure.html
Example of how to declare an entity in entities.xml. This is required for any entity that has been defined in entity_defs.
```xml
```
--------------------------------
### Linux Server Start/Stop Commands
Source: https://www.kbelab.com/manual/install.html
Execute these shell commands to start and stop the KBEngine server on a Linux system. Ensure you are in the correct directory.
```bash
# (Assuming engine installation directory is root/kbengine)
[kbe @gameserver ~]$ cd root/kbengine/getstarted_assets/scripts
[kbe @gameserver ~]$ sh start_server.sh
[kbe @gameserver ~]$ sh kill_server.sh
```
--------------------------------
### Error Code Structure Example
Source: https://www.kbelab.com/basic/config/errors.html
An example of a single error code configuration, showing its components: id and description.
```xml
0
成功。
...
```
--------------------------------
### Test WebSocket Handshake with wscat
Source: https://www.kbelab.com/advance/deploy/wss.html
Utilize wscat to test WebSocket handshake and connection establishment. Install via npm if not present. Supports testing with custom headers.
```bash
wscat -c wss://yourdomain.com/
# Or test with headers
wscat -H "Origin: https://yourdomain.com" -c wss://yourdomain.com/
```
--------------------------------
### KBEngine Get Resource Full Path API
Source: https://www.kbelab.com/basic/structure.html
Demonstrates the KBEngine.getResFullPath API, which converts a relative path within the res folder to an absolute path.
```python
# 2: 获取资源绝对路径:KBEngine.getResFullPath(relativeResPath)
```
--------------------------------
### Baseapp Configuration
Source: https://www.kbelab.com/advance/deploy/distributed/cloud.html
Configure the Baseapp component similarly to Loginapp by changing the root tag. This is essential for the base application server's network setup.
```xml
ip_internal
ip_external
ip_external
20013
0
```
--------------------------------
### Add Space Geometry Mapping with Navmesh Parameters
Source: https://www.kbelab.com/basic/motion/motion.html
An example of calling addSpaceGeometryMapping with specific navigation mesh files for different layers.
```python
KBEngine.addSpaceGeometryMapping(self.spaceID, None, resPath, True, {0 : "srv_xinshoucun_1.navmesh", 1 : "srv_xinshoucun.navmesh"})
```
--------------------------------
### Cellapp Internal Interface Configuration
Source: https://www.kbelab.com/advance/deploy/distributed/cloud.html
Configure the internal interface for Cellapp in kbengine.xml. This allows other internal apps to discover the Cellapp's internal network address in a distributed setup.
```xml
ip_internal
...
```
--------------------------------
### KBEngine Windows Startup Script Breakdown
Source: https://www.kbelab.com/manual/install.html
This batch script configures environment variables and launches various KBEngine server components. Pay attention to the 'cid' and 'gus' parameters for component identification and UUID generation.
```batch
@echo off
set curpath=%~dp0
cd ..
set KBE_ROOT=%cd%
set KBE_RES_PATH=%KBE_ROOT%/kbe/res/;%curpath%/;%curpath%/;%curpath%/res/
set KBE_BIN_PATH=%KBE_ROOT%/kbe/bin/server/
if defined uid (echo UID = %uid%) else set uid=%random%%%32760+1
cd %curpath%
call "kill_server.bat"
echo KBE_ROOT = %KBE_ROOT%
echo KBE_RES_PATH = %KBE_RES_PATH%
echo KBE_BIN_PATH = %KBE_BIN_PATH%
start %KBE_BIN_PATH%/machine.exe --cid=1000 --gus=1
start %KBE_BIN_PATH%/logger.exe --cid=2000 --gus=2
start %KBE_BIN_PATH%/interfaces.exe --cid=3000 --gus=3
start %KBE_BIN_PATH%/dbmgr.exe --cid=4000 --gus=4
start %KBE_BIN_PATH%/baseappmgr.exe --cid=5000 --gus=5
start %KBE_BIN_PATH%/cellappmgr.exe --cid=6000 --gus=6
start %KBE_BIN_PATH%/baseapp.exe --cid=7001 --gus=7
start %KBE_BIN_PATH%/cellapp.exe --cid=8001 --gus=9
start %KBE_BIN_PATH%/loginapp.exe --cid=9000 --gus=11
```
--------------------------------
### Windows Server Start/Stop Commands
Source: https://www.kbelab.com/manual/install.html
Use these batch commands to initiate and halt the KBEngine server on Windows. Navigate to the script directory first.
```batch
// (Assuming engine installation directory is d:/kbengine/)
cd d:/kbengine/getstarted_assets/scripts
start_server.bat
kill_server.bat
```
--------------------------------
### Get Space Custom Data
Source: https://www.kbelab.com/basic/motion/motion.html
Retrieves custom string data associated with a specific space using its key.
```python
KBEngine.getSpaceData(spaceID, key)
```
--------------------------------
### 配置服务器网络接口
Source: https://www.kbelab.com/basic/config/howto_multiple.html
在kbengine.xml文件中为不同服务器组件配置内部和外部网络接口。根据服务器类型,可能需要将内部和外部接口都设置为内部网卡。
```xml
...
eth1
eth0
...
eth1
eth0
...
eth1
eth0
...
eth1
eth1
eth1
eth1
eth1
eth1
eth1
eth1
eth1
eth1
eth1
eth1
```
--------------------------------
### Linux下网络路由配置
Source: https://www.kbelab.com/basic/config/howto_multiple.html
在Linux环境下,执行额外的命令来调整网络路由,以确保多网卡配置的正确性。这些命令用于修改特定设备的广播地址路由。
```bash
/sbin/ip route del broadcast 255.255.255.255 dev eth0
/sbin/ip route add broadcast 255.255.255.255 dev eth1
```
--------------------------------
### C# Client Configuration for WSS Mapping
Source: https://www.kbelab.com/advance/deploy/wss.html
This C# code snippet demonstrates how to configure domain and port mappings for WSS connections within a Unity KBEngine client application. It maps local IP addresses and ports to your WSS domain and corresponding SSL ports.
```csharp
using UnityEngine;
using System;
using System.Collections;
using KBEngine;
public class clientapp : UnityKBEMain
{
public clientapp()
{
KBELog.Init(new UnityLogProvider());
domainMapping.Add("127.0.0.1","kbe.com");
domainMapping.Add("192.168.1.3","kbe.com");
domainMapping.Add("192.168.36.128","wss.kbelab.com");
portMapping.Add(20013,443);
portMapping.Add(20015,444);
}
}
```
--------------------------------
### Loginapp Configuration
Source: https://www.kbelab.com/advance/deploy/distributed/cloud.html
Configure the Loginapp component in kbengine.xml, specifying internal and external network interfaces and ports. Use this when setting up the login service for your distributed application.
```xml
ip_internal
ip_external
ip_external
20013
0
```
--------------------------------
### Configure Single Bot Instance
Source: https://www.kbelab.com/advance/debug/bots.html
XML configuration to set the total number of bots to 1 for development debugging.
```xml
1
0.1
1
```
--------------------------------
### Baseapp Auto Backup Configuration
Source: https://www.kbelab.com/advance/deploy/distributed/disaster.html
Configure automatic entity backup settings for Baseapps, including the backup interval and whether to include undefined properties. These settings are defined in kbengine.xml.
```xml
...
300
0
...
```
--------------------------------
### KBEngine Root Directory Structure
Source: https://www.kbelab.com/basic/structure.html
Overview of the main directories within the KBEngine root (KBE_ROOT). This includes assets, docs, and the kbe engine directory.
```plaintext
|- kbengine (KBE_ROOT 根目录)
|- assets (默认的游戏项目资产库,所有的游戏逻辑,Python文件)
|- res (所有资源文件)
|- scripts (服务端管理脚本)
|- base-------------(Base的Python逻辑)
|- Account.py----------(默认的账户处理脚本)
|- kbemain.py----------(baseapp的入口脚本)
|- bots-------------(机器人的Python逻辑,压力测试)
|- kbemain.py----------(bots的入口脚本)
|- cell-------------(Cell的Python逻辑)
|- kbemain.py----------(cellapp的入口脚本)
|- common-----------(逻辑公共文件夹)
|- Functor.py----------(Functor实现脚本)
|- KBEDebug.py---------(Debug日志的辅助脚本)
|- data-------------(游戏逻辑用到的数据资源)
|- db---------------(dbmgr扩展脚本)
|- kbemain.py----------(dbmgr的入口脚本)
|- entity_defs------(实体定义与声明)
|- interfaces----------(实体的接口声明)
|- Account.def---------(Account的申明)
|- types.xml-----------(自定义类型的申明)
|- interface--------(第三方服务接口的脚本)
|- logger-----------(logger的逻辑)
|- login------------(LoginApp的逻辑)
|- server_common----(服务端逻辑公共模块)
|- user_type--------(自定义用户类型目录)
|- entities.xml-----(所有entity实体申明的配置文件)
|- docs (离线文档)
|- kbe (引擎目录)
|- tools (引擎工具)
|- src (KBEngine源代码)
|- res (引擎资源目录)
```
--------------------------------
### KBEngine Check Resource Existence API
Source: https://www.kbelab.com/basic/structure.html
Demonstrates the KBEngine.hasRes API, which checks for the existence of a resource using a relative path.
```python
# 3:检查是否有某个资源:KBEngine.hasRes(relativeResPath)
该api的参数res,也是相对路径,相对于res文件夹的。
```
--------------------------------
### KBEngine Engine Directory Structure
Source: https://www.kbelab.com/basic/structure.html
Overview of the directories within the kbe engine directory. This includes bin, res, src, and tools.
```plaintext
|- kbe
|- bin ------------(编译后的可执行文件存放目录)
|- server -----------(编译后的服务端可执行文件存放目录)
|- res ------------(引擎内部的资源目录)
|- client -----------(输出客户端sdk时的一些资源,如sdk template)
|- key---------------(RSA密钥)
|- scripts-----------(Python脚本库)
|- server------------(服务端引擎的默认配置)
|- src-------------(Cell的Python逻辑)
|- build-------------(makefile公共脚本)
|- client------------(客户端插件和例子目录)
|- lib---------------(各种模块源代码)
|- libs--------------(编译后的*.lib, *.a文件)
|- server------------(服务端app源代码)
|- kbengine_vsxx.sln (工程文件)
|- Makefile----------(makefile编译文件)
|- tools-----------(引擎工具)
|- server------------(引擎服务端工具)
|- xlsx2py-----------(游戏数据表导出工具)
```
--------------------------------
### Query Server Information with PyCluster
Source: https://www.kbelab.com/advance/debug/pycluster.html
Use the 'query' command to retrieve detailed information about running server processes, including CPU and memory usage, process IDs, and component-specific metrics. This command is useful for monitoring server health and resource allocation.
```bash
[kbe@gameserver ~]$
python $KBE_ROOT/kbe/tools/server/pycluster/cluster_controller.py query
/-----------------------------------------------------
[machine: %CPU:16.24, %MEM:13.54, %pCPU:0.00, pMem:11.79m, totalMem=1070.44m/7908.32m, addr=192.168.11.11]
proc cid uid pid gid %CPU %MEM usedMem extra1 extra2 extra3
|- loginapp 1657324666764709631 500 2682 23 0.11 0.47 37.45m 0 0 0
|- baseapp1 1080863912448030096 500 27131 15 1.28 0.79 62.71m bases=125 clients=60 proxices=120
|- baseapp2 1152921505798081463 500 27610 16 0.87 0.77 61.02m bases=107 clients=52 proxices=104
|- baseapp3 1224979099450159447 500 28097 17 0.89 0.78 61.63m bases=110 clients=53 proxices=107
|- baseapp4 1297036693135742534 500 28572 18 0.88 0.77 60.88m bases=93 clients=45 proxices=90
|- baseapp5 1369094286838111473 500 29050 19 0.88 0.77 60.51m bases=124 clients=61 proxices=121
|- baseapp6 1441151884785180883 500 29530 20 0.88 0.77 60.65m bases=106 clients=52 proxices=103
|- baseapp7 1513209478470765373 500 29993 21 1.03 0.77 61.11m bases=126 clients=62 proxices=124
|- baseapp8 1585267072156340434 500 30461 22 0.81 0.78 61.57m bases=83 clients=40 proxices=80
/-----------------------------------------------------
[machine: %CPU:5.29, %MEM:11.81, %pCPU:0.00, pMem:11.86m, totalMem=934.02m/7908.32m, addr=192.168.11.12]
proc cid uid pid gid %CPU %MEM usedMem extra1 extra2 extra3
|- dbmgr 288230377158391198 500 17940 4 0.64 0.73 57.68m 0 0 0
|- baseappmgr 360287971162772698 500 17941 5 1.27 0.45 35.62m 0 0 0
|- cellappmgr 432345565217478829 500 17942 6 0.00 0.16 12.74m 0 0 0
|- interfaces 144115189132878121 500 17939 2 0.00 0.49 38.73m 0 0 0
/-----------------------------------------------------
[machine: %CPU:2.48, %MEM:11.65, %pCPU:0.00, pMem:11.82m, totalMem=921.06m/7908.32m, addr=192.168.11.13]
proc cid uid pid gid %CPU %MEM usedMem extra1 extra2 extra3
|- cellapp1 504403161688137595 500 30217 7 0.35 0.66 52.17m entities=49 cells=0 0
|- cellapp2 576460755071688378 500 30221 8 0.35 0.64 50.66m entities=47 cells=0 0
|- cellapp3 648518348774108774 500 30225 9 0.34 0.64 50.51m entities=54 cells=0 0
|- cellapp4 720575942459711730 500 30229 10 0.38 0.64 50.85m entities=55 cells=0 0
|- cellapp5 792633536145339277 500 30233 11 0.37 0.64 50.59m entities=39 cells=0 0
|- cellapp6 864691129830946700 500 30237 12 0.33 0.64 50.61m entities=56 cells=0 0
|- cellapp7 936748723516524832 500 30241 13 0.35 0.64 50.58m entities=32 cells=0 0
|- cellapp8 1008806317202177300 500 30245 14 0.33 0.64 50.47m entities=59 cells=0 0
/-----------------------------------------------------
machines: 3, components=21, numBases=874, numProxices=849, numClients=425, numEntities=391, numCells=0.
```
--------------------------------
### Machine Component Network Configuration
Source: https://www.kbelab.com/advance/deploy/distributed/cloud.html
Configure the Machine component's addresses in kbengine.xml to specify network addresses for UDP broadcast when it's restricted in cloud environments. This ensures proper network discovery and组网 (network formation).
```xml
...
- 127.0.0.1
- ip_internal
- ip_internal2
...
```
--------------------------------
### KBEngine.onSpaceGeometryLoaded and KBEngine.onAllSpaceGeometryLoaded
Source: https://www.kbelab.com/basic/motion/motion.html
Callback functions to check the status of geometry loading for a space. `onSpaceGeometryLoaded` is called when the mesh and collision data for a space is loaded, while `onAllSpaceGeometryLoaded` is called when all required mesh and collision data for the space has been completely loaded.
```APIDOC
## KBEngine.onSpaceGeometryLoaded and KBEngine.onAllSpaceGeometryLoaded
### Description
Callback functions to check the status of geometry loading for a space. `onSpaceGeometryLoaded` is called when the mesh and collision data for a space is loaded, while `onAllSpaceGeometryLoaded` is called when all required mesh and collision data for the space has been completely loaded.
### API
* KBEngine.onSpaceGeometryLoaded(spaceID, mapping)
* KBEngine.onAllSpaceGeometryLoaded(spaceID, isBootstrap, mapping)
### Parameters
* **KBEngine.onSpaceGeometryLoaded**:
* **spaceID** (int) - The ID of the space.
* **mapping** (float) - The mapping value for mesh collision data.
* **KBEngine.onAllSpaceGeometryLoaded**:
* **spaceID** (int) - The ID of the space.
* **isBootstrap** (bool) - Describes whether this is the initiating cell for a space split across multiple cells.
* **mapping** (float) - The mapping value for mesh collision data.
```
--------------------------------
### TypeScript Client Configuration for WSS Mapping (Cocos)
Source: https://www.kbelab.com/advance/deploy/wss.html
This TypeScript code snippet shows how to configure domain and port mappings for WSS connections in a Cocos-based KBEngine client. It sets up the KBEngineApp with WSS enabled and defines the necessary domain and port mappings.
```typescript
// 关键代码
@ccclass
@disallowMultiple
export class ServerNode extends Component {
@property
ip="127.0.0.1"
onLoad(){
this.initServerApp()
director.addPersistRootNode(this.node);
}
initServerApp():void {
log("init Server App")
let args = new KBEngineArgs();
args.address=this.ip
args.port = 20013;
args.useWss = true;
args.domainMapping["192.168.36.128"] = "wss.kbelab.com";
args.portMapping[20013] = 443;
args.portMapping[20015] = 444;
KBEngineApp.Destroy();
KBEngineApp.Create(args)
}
}
```
--------------------------------
### KBEngine.setSpaceData and KBEngine.getSpaceData
Source: https://www.kbelab.com/basic/motion/motion.html
APIs for setting and retrieving custom data associated with a specific space. `setSpaceData` allows you to store data using a key-value pair, while `getSpaceData` retrieves the data associated with a given key.
```APIDOC
## KBEngine.setSpaceData and KBEngine.getSpaceData
### Description
APIs for setting and retrieving custom data associated with a specific space. `setSpaceData` allows you to store data using a key-value pair, while `getSpaceData` retrieves the data associated with a given key.
### API
* KBEngine.setSpaceData(spaceID, key, value)
* KBEngine.getSpaceData(spaceID, key)
### Parameters
* **KBEngine.setSpaceData**:
* **spaceID** (int) - Required - The ID of the space.
* **key** (string) - Required - A string keyword.
* **value** (string) - Required - The data to be stored.
* **KBEngine.getSpaceData**:
* **spaceID** (int) - Required - The ID of the space.
* **key** (string) - Required - A string keyword.
```
--------------------------------
### KBEngine.addSpaceGeometryMapping
Source: https://www.kbelab.com/basic/motion/motion.html
Associates geometry data with a given space. This function loads the corresponding geometry data on both the server and client. On the server, it loads all geometry data from the specified directory into the designated space, with potential asynchronous loading of different chunks. The server uses this data for navigation and collision, while the client also loads textures and other assets.
```APIDOC
## KBEngine.addSpaceGeometryMapping
### Description
Associates geometry data with a given space. This function loads the corresponding geometry data on both the server and client. On the server, it loads all geometry data from the specified directory into the designated space, with potential asynchronous loading of different chunks. The server uses this data for navigation and collision, while the client also loads textures and other assets.
### API
KBEngine.addSpaceGeometryMapping(spaceID, mapping, path, shouldLoadOnServer, params)
### Parameters
* **spaceID** (int) - Required - The ID of the space to which geometry data will be added.
* **mapping** - Required - The mapping value for mesh collision data.
* **path** (string) - Required - The directory path containing the geometry data. This path is relative to the project's resource folder ({Project Asset Library}/res).
* **shouldLoadOnServer** (bool) - Optional - Specifies whether to load geometry on the server. Defaults to True.
* **params** (dict) - Optional - Specifies the navmesh to be used for different layers. Example: `{0 : "srv_xinshoucun_1.navmesh", 1 : "srv_xinshoucun.navmesh"}`
### Notes
Geometry data loading is an asynchronous process.
```
--------------------------------
### Unity Position Conversion
Source: https://www.kbelab.com/client/handsystem.html
Convert KBE logic layer coordinates to Unity's coordinate system by flipping the X-axis.
```plaintext
x' = -x
y' = y
z' = z
```
--------------------------------
### Entity.navigate
Source: https://www.kbelab.com/basic/motion/motion.html
Uses the navigation system to move an entity towards a target point. Success or failure will trigger a callback function. This method is used when `Entity.canNavigate()` returns true.
```APIDOC
## Entity.navigate
### Description
Uses the navigation system to move an entity towards a target point. Success or failure will trigger a callback function. This method is used when `Entity.canNavigate()` returns true.
### API
Entity.navigate(self, destination, velocity, distance, maxMoveDistance, maxSearchDistance, faceMovement, layer, userData)
### Parameters
* **destination** (Vector3) - Required - The target point the entity will move towards.
* **velocity** (float) - Required - The movement speed in m/s.
* **distance** (float) - Required - The entity stops moving when it is within this distance of the target. If this value is 0, the entity will move to the target position.
* **maxMoveDistance** (float) - Required - The maximum movement distance.
* **maxSearchDistance** (float) - Required - The maximum search distance from the navigation data.
* **faceMovement** (bool) - Required - If True, the entity faces the direction of movement. If False, it does not. Generally set to True unless the entity has no orientation, like an explosive barrel.
* **layer** (int8) - Required - The layer of the navmesh to use for pathfinding.
* **userData** (object) - Optional - Custom user data to be passed to the callback function.
```
--------------------------------
### DBMgr Database Connection Configuration
Source: https://www.kbelab.com/advance/deploy/distributed/cloud.html
Configure the DBMgr component in kbengine.xml to establish database connections, including host, port, username, password, and encryption settings. This is crucial for data management in distributed systems.
```xml
...
...
你的数据库内网地址
你的数据库内网端口
你的数据库用户名
你的数据库登录密码
true
```
--------------------------------
### Nginx Configuration for BaseApp WSS Proxy
Source: https://www.kbelab.com/advance/deploy/wss.html
This Nginx configuration block proxies WebSocket (WSS) traffic for the BaseApp. It requires similar adjustments for domain, ports, and certificate paths as the LoginApp configuration. Use this within Baota Panel's site configuration.
```nginx
# baseapp 代理
server
{
listen 802;
listen 444 ssl; # 替换为你端口
http2 on;
server_name wss.kbelab.com;# 替换为你的域名
ssl_certificate /www/server/panel/vhost/cert/wss.kbelab.com/fullchain.pem; # 替换为你的证书
ssl_certificate_key /www/server/panel/vhost/cert/wss.kbelab.com/privkey.pem; # 替换为你的证书
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_tickets on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
location / {
proxy_pass http://127.0.0.1:20015;
proxy_http_version 1.1;
# WebSocket 专用头
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
# 传递真实 IP
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 防止连接超时
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
access_log /www/wwwlogs/wss.kbelab.com.log;
error_log /www/wwwlogs/wss.kbelab.com.error.log;
}
```
--------------------------------
### Enable Core Dumps on Linux
Source: https://www.kbelab.com/advance/debug
Configure your system to generate core dump files for debugging C++ engine code. This involves modifying the .bashrc file and system core pattern settings.
```bash
#在~/.bashrc中添加如下命令:
ulimit -c unlimited
#需要root权限执行:
[root@gameserver ~]# echo '%e.core.%p' > /proc/sys/kernel/core_pattern
```
--------------------------------
### Default Engine Error Codes
Source: https://www.kbelab.com/basic/config/errors.html
A comprehensive list of default engine error codes, including their IDs and descriptions. This file serves as the default configuration.
```xml
0
成功。
1
服务器没有准备好。
2
服务器负载过重。
3
非法登录。
4
用户名或者密码不正确。
5
用户名不正确。
6
密码不正确。
7
创建账号失败(已经存在一个相同的账号)。
8
操作过于繁忙(例如:在服务器前一次请求未执行完毕的情况下连续N次创建账号)。
9
当前账号在另一处登录了。
10
账号已登陆。
11
与客户端关联的proxy在服务器上已经销毁。
12
EntityDefs不匹配。
13
服务器正在关闭中。
14
Email地址错误。
15
账号被冻结。
16
账号已过期。
17
账号未激活。
18
与服务端的版本不匹配。
19
操作失败。
20
服务器正在启动中。
21
未开放账号注册功能。
22
不能使用email地址。
23
找不到此账号。
24
数据库错误(请检查dbmgr日志和DB)。
25
用户自定义错误码1。
...
...
34
用户自定义错误码10。
35
本地处理,通常为某件事情不由第三方处理而是由KBE服务器处理。
36
未开放账号重置密码功能。
37
当前账号在其他服务器登陆了。
```
--------------------------------
### Baseapp Auto Archiving Configuration
Source: https://www.kbelab.com/advance/deploy/distributed/disaster.html
Configure the automatic data archiving period for Baseapps in the kbengine.xml file. This setting determines how frequently entity properties are saved to the database.
```xml
...
300
...
```
--------------------------------
### Account Bot Logic
Source: https://www.kbelab.com/advance/debug/bots.html
Python script for the Account bot entity, simulating client requests for character lists and creation.
```python
class Account(KBEngine.Entity):
def __init__(self):
KBEngine.Entity.__init__(self)
DEBUG_MSG("Account::__init__:%s." % (self.__dict__))
self.base.reqAvatarList()
def onReqAvatarList(self, infos):
"""
defined method.
"""
DEBUG_MSG("Account:onReqAvatarList::%s" % (list(infos['values'])))
self.base.reqCreateAvatar(1, "kbe_bot_%s" % self.id)
self.characters = copy.deepcopy(infos["values"])
def onCreateAvatarSuccess(self, info):
"""
defined method.
"""
DEBUG_MSG("Account:onCreateAvatarSuccess::%s" % (dict(info)))
def onCreateAvatarFailed(self, errorCode):
"""
defined method.
"""
ERROR_MSG("Account:onCreateAvatarFailed:: errorCode=%i" % (errorCode))
```
--------------------------------
### Unreal Engine Position Conversion
Source: https://www.kbelab.com/client/handsystem.html
Convert KBE logic layer coordinates to Unreal Engine's system, flipping X and swapping Y/Z, and scaling by 100 due to unit differences.
```plaintext
x' = x * 100
y' = z * 100
z' = y * 100
```
--------------------------------
### Entity Navigation Check and Movement
Source: https://www.kbelab.com/basic/motion/motion.html
Determines if an entity can navigate and then uses either the navigation system or a basic move to point function.
```python
def gotoPosition(self, position, dist=0.0):
"""
移动到某个位置
:param position:Vector3, 目标位置点
:param dist: float, 达到多少距离则判定为到达
:return:
"""
if self.position.distTo(position) <= 0.05: # 阈值0.05,如果小于,则不进行移动
return
self.isMoving = True
speed = self.moveSpeed * 0.1
if self.owner.canNavigate():
DEBUG_MSG("Motion(%s[%i])::gotoPosition: canNavigate=True" % (self.owner.getScriptName(), self.ownerID))
self.owner.navigate(Math.Vector3(position), speed, dist, speed, 512.0, True, 0, None)
else:
WARNING_MSG("Motion(%s[%i])::gotoPosition: position=%s canNavigate=False" % (self.owner.getScriptName(), self.ownerID, position))
self.owner.moveToPoint(position, speed, dist, None, True, False)
```
--------------------------------
### Unity Rotation Conversion
Source: https://www.kbelab.com/client/handsystem.html
Convert KBE logic layer yaw to Unity's yaw by negating it. Note that protocol's z represents yaw.
```plaintext
yaw' = -yaw
```
--------------------------------
### Stop Server Components with PyCluster
Source: https://www.kbelab.com/advance/debug/pycluster.html
Gracefully shut down server components using the 'stop' command. This command is used to halt all running server processes managed by PyCluster. Ensure the KBE_ROOT environment variable is set.
```bash
[kbe@gameserver ~]$
python $KBE_ROOT/kbe/tools/server/pycluster/cluster_controller.py stop
```
--------------------------------
### View Nginx Access and Error Logs
Source: https://www.kbelab.com/advance/deploy/wss.html
Monitor Nginx access and error logs in real-time to diagnose connection issues and server-side errors. Log file locations may vary (e.g., /www/wwwlogs).
```bash
# Access logs
tail -f /www/wwwlogs/yourdomain.access.log
# Error logs
tail -f /www/wwwlogs/yourdomain.error.log
```
--------------------------------
### Cocos Creator Position Conversion
Source: https://www.kbelab.com/client/handsystem.html
Convert KBE logic layer coordinates to Cocos Creator's system by flipping X and swapping Y/Z axes.
```plaintext
x' = -x
y' = z
z' = y
```