上次弄pomelo已经是去年12月了,后来忙其他的事情就没研究下去。
今年初有个同事离职去广州和朋友创业,在我的鼓吹下他们决定使用pomelo做服务器。所谓万事开头难,他第一次装pomelo就诸事不顺,一些基本的问题经过google后得到了解决,不过最后还是有点问题解决不了。于是我也重新装了一次新版的pomelo,果然是有点啃爹,照着官方说明无法成功启动helloworld,鼓捣了几个小时弄清楚了问题所在。
首先是游戏服务器启动错误
[2013-03-10 18:07:55.048] [ERROR] console - FAILED TO RUN, return code: 1 [2013-03-10 18:07:55.052] [ERROR] console - Caught exception: TypeError: undefined is not a function at starter.localrun (/Users/andylee/pomeloProject/helloWorld/game-server/node_modules/pomelo/lib/master/starter.js:136:7) at ChildProcess.spawnProcess (/Users/andylee/pomeloProject/helloWorld/game-server/node_modules/pomelo/lib/master/starter.js:191:7) at ChildProcess.EventEmitter.emit (events.js:99:17) at Process._handle.onexit (child_process.js:678:10)
新版本的pomelo为移动端优化,新增了基于字典的route压缩和基于protobuf的传输数据压缩。其中涉及到3个定义文件
/game-server/config中的dictionary.json clientProtos.json serverprotos.json
这3个文件创建工程的时候是空的,这导致了上面错误。
解决方法:在这3个文件中都加入{}
然后是网页服务器,点击测试页面的“Test game server”按钮没有服务器的反馈提示.
新版本的pomelo引入了component来管理js的库,所以原来的js客户端默认已经不存在了,这就导致连接不上服务器。
解决方法:
首先运行npm install -g component 安装component(权限问题需要加sudo)
然后在web-server目录下执行
sh bin/component.sh