Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add fail ids for channel push method

Change-Id: I195ee1c5c27da4d496213bf00db220414b7dc1aa
  • Loading branch information...
commit c7993e725c1e730e10f058e3a7ae7a4d40d90e7a 1 parent e73b0ef
@changchang changchang authored
View
4 Makefile
@@ -3,7 +3,7 @@ REPORTER = spec
TIMEOUT = 5000
test:
- @./node_modules/.bin/mocha \
- --reporter $(REPORTER) --timeout $(TIMEOUT) $(TESTS)
+ @./node_modules/.bin/mocha \
+ --reporter $(REPORTER) --timeout $(TIMEOUT) $(TESTS)
.PHONY: test
View
9 lib/common/remote/frontend/channelRemote.js
@@ -21,8 +21,11 @@ var Remote = function(app) {
*/
Remote.prototype.pushMessage = function(msg, uids, cb) {
var sessionService = this.app.get('sessionService');
+ var fails = [];
for(var i=0, l=uids.length; i<l; i++) {
- sessionService.sendMessageByUid(uids[i], msg);
+ if(!sessionService.sendMessageByUid(uids[i], msg)) {
+ fails.push(uids[i]);
+ }
}
- cb();
-};
+ cb(null, fails);
+};
View
8 lib/common/service/channelService.js
@@ -249,6 +249,7 @@ var sendMessageByGroup = function(channelService, msg, groups, cb) {
var method = 'pushMessage';
var count = utils.size(groups);
var successFlag = false;
+ var failIds = [];
msg = JSON.stringify(msg);
if(count === 0) {
@@ -262,17 +263,20 @@ var sendMessageByGroup = function(channelService, msg, groups, cb) {
utils.invokeCallback(cb, new Error('all uids push message fail'));
return;
}
- utils.invokeCallback(cb);
+ utils.invokeCallback(cb, null, failIds);
});
for(var sid in groups) {
var uids = groups[sid];
- app.rpcInvoke(sid, {namespace: namespace, service: service, method: method, args: [msg, uids]}, function(err) {
+ app.rpcInvoke(sid, {namespace: namespace, service: service, method: method, args: [msg, uids]}, function(err, fails) {
if(err) {
logger.error('[pushMessage] fail to dispatch msg, err:' + err.stack);
latch.done();
return;
}
+ if(fails) {
+ failIds = failIds.concat(fails);
+ }
successFlag = true;
latch.done();
});
Please sign in to comment.
Something went wrong with that request. Please try again.