Add a third level construct under Profile and Client, Instance. This allows more than one connected object with the same client credentials.
This commit is contained in:
@@ -45,6 +45,8 @@ var Cosmopolite = function(callbacks, urlPrefix, namespace) {
|
||||
this.subscriptions_ = {};
|
||||
this.profilePromises_ = [];
|
||||
|
||||
this.instanceId_ = this.uuid_();
|
||||
|
||||
this.messageQueueKey_ = this.namespace_ + ':message_queue';
|
||||
if (this.messageQueueKey_ in localStorage) {
|
||||
var messages = JSON.parse(localStorage[this.messageQueueKey_]);
|
||||
@@ -447,6 +449,7 @@ Cosmopolite.prototype.sendRPCs_ = function(commands, delay) {
|
||||
return;
|
||||
}
|
||||
var request = {
|
||||
'instance_id': this.instanceId_,
|
||||
'commands': [],
|
||||
};
|
||||
commands.forEach(function(command) {
|
||||
|
||||
@@ -441,6 +441,32 @@ asyncTest('sendMessage ACL', function() {
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest('Two channels, one client', function() {
|
||||
expect(2);
|
||||
|
||||
var namespace = randstring();
|
||||
var subject = randstring();
|
||||
var message = randstring();
|
||||
|
||||
var callbacks = {
|
||||
'onMessage': function(msg) {
|
||||
console.log('onMessage');
|
||||
equal(msg['subject']['name'], subject, 'subject matches');
|
||||
equal(msg['message'], message, 'message matches');
|
||||
cosmo1.shutdown();
|
||||
start();
|
||||
},
|
||||
};
|
||||
|
||||
var cosmo1 = new Cosmopolite(callbacks, null, namespace);
|
||||
cosmo1.subscribe(subject).then(function() {
|
||||
var cosmo2 = new Cosmopolite({}, null, namespace);
|
||||
cosmo2.sendMessage(subject, message).then(function() {
|
||||
cosmo2.shutdown();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module('dev_appserver only');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user