ubuntu安裝nodejs+pomelo+webstrom

來源:互聯網
上載者:User
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.js

onlineUser.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.js

utils.js內容為:

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 ~ 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 <= 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 ~ end
然後在重新運行game-server中的app.js就可以了

以上就介紹了ubuntu安裝nodejs+pomelo+webstrom,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.