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 Click to open 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 in/usr/webserver/new_pomelo/chatofpomelo-websocket# npm install Pomelo-logger
If the Unknown module: "Onlineuser" appears in the log. Just add it in 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});});
Add onlineuser files to Game-server-->app and add onlineuser.js
The content in Onlineuser.js is
/*! * Pomelo-Consolemodule Onlineuser * Copyright (c) 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 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 = a gent.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.mo Duleid));};
and add Utils.js in the Game-server-->app->util
Utils.js content is:
var utils = module.exports;//control variable of func "Myprint" var isprintflag = false;//var isprintflag = true;/** * Ch Eck 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
And then re-run the app.js in Game-server.
The above describes the Ubuntu installation Nodejs+pomelo+webstrom, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.