以官方聊天室 demo 为例,演示如何为 Pomelo 添加一个 time 服务器并配置远程调用。
1. 添加 time 的远程调用
新建文件 \game-server\app\servers\time\remote\timeRemote.js:
直接导出函数 getCurrentTime 即可,当然也可以导出对象。
2. 在 app.js 中添加路由
打开 app.js,为新增的 time 服务器添加对应的路由配置。
3. 配置 servers.json
在 servers.json 中添加 time 服务器的配置:
运行后如果提示启动 time-server-1 失败,检查后发现是 config 目录下的 adminServer.json 文件导致的。
解决方法:在 adminServer.json 中添加相应配置:
或者直接删掉该文件也可以解决问题。