Home >Backend Development >PHP Tutorial >Install nodejs+pomelo+webstrom on ubuntu
https://github.com/NetEase/pomelo/wiki/pomelo%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D %97Click to open the link
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
If Cannot find module 'pomelo-logger' appears Just at /usr/webserver/new_pomelo/chatofpomelo-websocket# npm install pomelo-logger
If unknown module: "onlineUser" appears in the log. Add
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}); } });to app.js and add the onlineUser file to game-server-->app-->Add onlineUser.js The content in
onlineUser.js is
/*! * Pomelo -- consoleModule onlineUser * Copyright(c) 2012 fantasyni <fantasyni@163.com> * 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)); };and add utils.js in game-server-->app->util
utils.js content is:
var utils = module.exports; // control variable of func "myPrint" var 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 ~ begin function 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 <= 0) { return; } var stack = getStack(); var aimStr = '\'' + getFileName(stack) + '\' @' + getLineNumber(stack) + ' :\n'; for(var i = 0; i < len; ++i) { aimStr += arguments[i] + ' '; } console.log('\n' + aimStr); } }; // print the file name and the line number ~ endand then re-run app.js in game-server
The above introduces the installation of nodejs+pomelo+webstrom on ubuntu, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.