Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var utils = require('../../util/utils');
var WebSocketServer = require('ws').Server;
var logger = require('pomelo-logger').getLogger('pomelo-rpc', __filename);
var Tracer = require('../../util/tracer');
var Acceptor = function(opts, cb){
EventEmitter.call(this);
this.bufferMsg = opts.bufferMsg;
this.interval = opts.interval; // flush interval in ms
this.rpcDebugLog = opts.rpcDebugLog;
this.rpcLogger = opts.rpcLogger;
this.whitelist = opts.whitelist;
this._interval = null; // interval object
this.sockets = {};
this.msgQueues = {};
this.cb = cb;
this.socketId = 0;
// Heartbeat ping interval.
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var utils = require('../../util/utils');
var net = require('net');
var Composer = require('../../util/composer');
var Tracer = require('../../util/tracer');
var logger = require('pomelo-logger').getLogger('pomelo-rpc', __filename);
var MSG_TYPE = 0;
var PING = 1;
var PONG = 2;
var RES_TYPE = 3;
var Acceptor = function(opts, cb) {
EventEmitter.call(this);
opts = opts || {};
this.bufferMsg = opts.bufferMsg;
this.interval = opts.interval; // flush interval in ms
this.pkgSize = opts.pkgSize;
this._interval = null; // interval object
// Heartbeat ping interval.
this.ping = 'ping' in opts ? opts.ping : 25e3;
module.exports = function(app, opts) {
opts = opts || {};
// cacheMsg is deprecated, just for compatibility here.
opts.bufferMsg = opts.bufferMsg || opts.cacheMsg || false;
opts.interval = opts.interval || 30;
if(app.enabled('rpcDebugLog')) {
opts.rpcDebugLog = true;
opts.rpcLogger = require('pomelo-logger').getLogger('rpc-debug', __filename);
}
return new Component(app, opts);
};
module.exports = function(app, opts) {
opts = opts || {};
// proxy default config
// cacheMsg is deprecated, just for compatibility here.
opts.bufferMsg = opts.bufferMsg || opts.cacheMsg || false;
opts.interval = opts.interval || 30;
opts.router = genRouteFun();
opts.context = app;
opts.routeContext = app;
if (app.enabled('rpcDebugLog')) {
opts.rpcDebugLog = true;
opts.rpcLogger = require('pomelo-logger').getLogger('rpc-debug', __filename);
}
return new Component(app, opts);
};
/*!
* Pomelo -- consoleModule nodeInfo processInfo
* Copyright(c) 2012 fantasyni
* MIT Licensed
*/
var monitor = require('pomelo-monitor');
var logger = require('pomelo-logger').getLogger('pomelo-admin', __filename);
var DEFAULT_INTERVAL = 5 * 60; // in second
var DEFAULT_DELAY = 10; // in second
module.exports = function(opts) {
return new Module(opts);
};
module.exports.moduleId = 'nodeInfo';
var Module = function(opts) {
opts = opts || {};
this.type = opts.type || 'pull';
this.interval = opts.interval || DEFAULT_INTERVAL;
this.delay = opts.delay || DEFAULT_DELAY;
};
'use strict';
var should = require('should');
var logger = require('pomelo-logger').getLogger('test', __filename);
var Q = require('q');
var Area = require('../../app/components/area');
describe('area test', function(){
it('invoke', function(cb){
var area = new Area({_id : 'area1'});
area.test('arg');
cb(null);
});
});
'use strict';
var env = require('../env');
var Q = require('q');
var sinon = require('sinon');
var util = require('util');
var logger = require('pomelo-logger').getLogger('test', __filename);
describe('areaProxy test', function(){
before(env.before);
beforeEach(env.beforeEach);
afterEach(env.afterEach);
after(env.after);
it('area proxy test', function(cb){
var app = env.createMockApp('server1', 'area');
var method = 'testInvoke';
var args = ['arg1', 'arg2'];
Q.nfcall(function(cb){
return app.start(cb);
}).then(function(){
'use strict';
var env = require('../env');
var Q = require('q');
var util = require('util');
var logger = require('pomelo-logger').getLogger('test', __filename);
describe('area test', function(){
before(env.before);
beforeEach(env.beforeEach);
afterEach(env.afterEach);
after(env.after);
it('create/remove/join/quit/login/logout/notify player', function(cb){
var connectorId = 'connector-server-1';
var areaId = 'area1';
var playerId = 'player1';
var app1 = env.createMockApp('server1', 'area');
var app2 = env.createMockApp('server2', 'area');
Q.fcall(function(){
'use strict';
var env = require('../env');
var Q = require('q');
var sinon = require('sinon');
var logger = require('pomelo-logger').getLogger('test', __filename);
var AreaManager = require('../../app/components/area-manager');
var AreaProxy = require('../../app/components/area-proxy');
describe('area-proxy test', function(){
before(env.before);
beforeEach(env.beforeEach);
afterEach(env.afterEach);
after(env.after);
it('areaProxy test', function(cb){
var fakeAreaServer = {
invokeArea : sinon.spy()
};
var fakeApp = {
rpc : { area :
'use strict';
var env = require('../env');
var Q = require('q');
var util = require('util');
var logger = require('pomelo-logger').getLogger('test', __filename);
describe('playerBackend test', function(){
before(env.before);
beforeEach(env.beforeEach);
afterEach(env.afterEach);
after(env.after);
it('create/acquire/release player', function(cb){
var serverId = 'area-server-1';
var areaId = 'area1';
var playerId = 'player1';
var app = env.createMockApp(serverId, 'area');
Q.nfcall(function(cb){
app.start(cb);