https://github.com/netease/pomelo/wiki/pomelo%e5%bf%ab%e9%80%9f%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97点击打开链接
https://github.com/netease/pomelo/wiki/tutorial1--%e5%88%86%e5%b8%83%e5%bc%8f%e8%81%8a%e5%a4%a9
https://github.com/netease/pomelo/wiki/home-in-chinese#%e6%bc%94%e7%a4%ba
如果出现 cannot find module 'pomelo-logger'就在 /usr/webserver/new_pomelo/chatofpomelo-websocket# npm install pomelo-logger
如果出现在日志中出现unknown module: onlineuser.就在app.js中添加
app.configure('production|development', function() { app.enable('systemmonitor'); var onlineuser = require('./app/onlineuser/onlineuser'); if(typeof app.registeradmin === 'function'){ //app.registeradmin(sceneinfo, {app: app}); app.registeradmin(onlineuser, {app: app}); }});
并在game-server-->app中添加 onlineuser文件-->添加onlineuser.jsonlineuser.js中的内容为
/*! * pomelo -- consolemodule onlineuser * copyright(c) 2012 fantasyni * mit licensed */var logger = require('pomelo-logger').getlogger(__filename);var utils = require('../util/utils');module.exports = function(opts) { return new module(opts);};module.exports.moduleid = 'onlineuser';var module = function(opts) { opts = opts || {}; this.app = opts.app; this.type = opts.type || 'pull'; this.interval = opts.interval || 5;};module.prototype.monitorhandler = function(agent, msg) { var connectionservice = this.app.components.__connection__; if(!connectionservice) { logger.error('not support connection: %j', agent.id); return; } agent.notify(module.exports.moduleid, connectionservice.getstatisticsinfo());};module.prototype.masterhandler = function(agent, msg) { if(!msg) { // pull interval callback var list = agent.typemap['connector']; if(!list || list.length === 0) { return; } agent.notifybytype('connector', module.exports.moduleid); return; } var data = agent.get(module.exports.moduleid); if(!data) { data = {}; agent.set(module.exports.moduleid, data); } data[msg.serverid] = msg;};module.prototype.clienthandler = function(agent, msg, cb) { utils.invokecallback(cb, null, agent.get(module.exports.moduleid));};
并在game-server-->app->util中添加utils.jsutils.js内容为:
var utils = module.exports;// control variable of func myprintvar isprintflag = false;// var isprintflag = true;/** * check and invoke callback function */utils.invokecallback = function(cb) { if(!!cb && typeof cb === 'function') { cb.apply(null, array.prototype.slice.call(arguments, 1)); }};/** * clone an object */utils.clone = function(origin) { if(!origin) { return; } var obj = {}; for(var f in origin) { if(origin.hasownproperty(f)) { obj[f] = origin[f]; } } return obj;};utils.size = function(obj) { if(!obj) { return 0; } var size = 0; for(var f in obj) { if(obj.hasownproperty(f)) { size++; } } return size;};// print the file name and the line number ~ beginfunction getstack(){ var orig = error.preparestacktrace; error.preparestacktrace = function(_, stack) { return stack; }; var err = new error(); error.capturestacktrace(err, arguments.callee); var stack = err.stack; error.preparestacktrace = orig; return stack;}function getfilename(stack) { return stack[1].getfilename();}function getlinenumber(stack){ return stack[1].getlinenumber();}utils.myprint = function() { if (isprintflag) { var len = arguments.length; if(len 然后在重新运行game-server中的app.js就可以了
以上就介绍了ubuntu安装nodejs+pomelo+webstrom,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。