Permalink
Browse files

channelServer.broadcast binded parameter to opts

  • Loading branch information...
1 parent 02aa316 commit 3aa7f9afc5312791b5164853efa74b9115adc087 @changchang changchang committed Mar 6, 2013
@@ -106,11 +106,12 @@ ChannelService.prototype.pushMessageByUids = function(route, msg, uids, cb) {
* @param {String} stype frontend server type string
* @param {String} route route string
* @param {Object} msg message
- * @param {Boolean} binded push to binded sessions or all the sessions
+ * @param {Boolean} opts broadcast options. opts.binded: push to binded sessions or all the sessions
* @param {Function} cb callback
* @memberOf ChannelService
*/
-ChannelService.prototype.broadcast = function(stype, route, msg, binded, cb) {
+ChannelService.prototype.broadcast = function(stype, route, msg, opts, cb) {
+ opts = opts || {};
var app = this.app;
var namespace = 'sys';
var service = 'channelRemote';
@@ -150,7 +151,7 @@ ChannelService.prototype.broadcast = function(stype, route, msg, binded, cb) {
for(var i=0, l=count; i<l; i++) {
app.rpcInvoke(servers[i].id, {namespace: namespace, service: service,
- method: method, args: [route, msg, binded]}, rpcCB);
+ method: method, args: [route, msg, opts.binded]}, rpcCB);
}
};
@@ -99,6 +99,9 @@ LocalSessionService.prototype.bind = function(frontendId, sid, uid, cb) {
* @param {String} key key in session that should be push
* @param {Object} value value in session, primitive js object
* @param {Function} cb callback function
+ *
+ * @memberOf SessionService
+ * @api private
*/
LocalSessionService.prototype.push = function(frontendId, sid, key, value, cb) {
var namespace = 'sys';
@@ -115,6 +118,9 @@ LocalSessionService.prototype.push = function(frontendId, sid, key, value, cb) {
* @param {Number} sid session id
* @param {Object} settings key/values in session that should be push
* @param {Function} cb callback function
+ *
+ * @memberOf SessionService
+ * @api private
*/
LocalSessionService.prototype.pushAll = function(frontendId, sid, settings, cb) {
var namespace = 'sys';
@@ -64,7 +64,7 @@ Connector.prototype.start = function() {
this.tcpServer.listen(this.port);
};
-Connector.prototype.close = function() {
+Connector.prototype.stop = function() {
this.switcher.close();
this.tcpServer.close();
};
View
@@ -98,7 +98,7 @@ var stop = function(app, agent, msg, cb) {
}
else {
agent.notifyAll(module.exports.moduleId, { signal: msg.signal });
- setTimeout(function(){
+ setTimeout(function(){
app.stop(true);
cb(null, { status: "all" });
},TIME_WAIT_STOP);
@@ -110,7 +110,7 @@ var list = function(agent, msg, cb) {
var serverInfo = {};
var count = utils.size(agent.idMap);
var latch = countDownLatch.createCountDownLatch(count, function() {
- cb(null, { msg: serverInfo });
+ cb(null, { msg: serverInfo });
});
for(sid in agent.idMap) {
@@ -130,7 +130,7 @@ var add = function(app, msg, cb) {
cb(new Error('Error server parameters format.'), null);
return;
}
- var pairs = args[i].split('=');
+ var pairs = args[i].split('=');
var key = pairs[0];
if(!!ServerInfo[key])
ServerInfo[key] = 'matched';
@@ -145,13 +145,15 @@ var add = function(app, msg, cb) {
return;
}
});
- process.nextTick(cb(null, { status: "ok" }));
+ process.nextTick(function() {
+ cb(null, { status: "ok" });
+ });
}
- else
+ else
cb(new Error('Miss necessary server parameters.'), null);
reset();
-};
+};
var ServerInfo = {
host: 'unmatched',
View
@@ -24,7 +24,7 @@ var Pomelo = module.exports = {};
* Framework version.
*/
-Pomelo.version = '0.2.x';
+Pomelo.version = '0.3.1';
/**
* Event definitions that would be emitted by app.event
@@ -203,6 +203,7 @@ describe('channel manager test', function() {
var mockSType = 'connector';
var mockRoute = 'test.route.string';
var mockBinded = true;
+ var opts = {binded: mockBinded};
var mockMsg = {key: 'some remote message'};
var invokeCount = 0;
@@ -227,7 +228,7 @@ describe('channel manager test', function() {
var channelService = new ChannelService(app);
channelService.broadcast(mockSType, mockRoute, mockMsg,
- mockBinded, function() {
+ opts, function() {
invokeCount.should.equal(2);
sids.length.should.equal(connectorIds.length);
for(var i=0, l=connectorIds.length; i<l; i++) {

0 comments on commit 3aa7f9a

Please sign in to comment.