|
|
|
@ -2,11 +2,12 @@ define([
|
|
|
|
|
'/common/common-util.js',
|
|
|
|
|
'/common/common-constants.js',
|
|
|
|
|
'/customize/messages.js',
|
|
|
|
|
'/customize/application_config.js',
|
|
|
|
|
'/bower_components/chainpad-crypto/crypto.js',
|
|
|
|
|
], function (Util, Constants, Messages, Crypto) {
|
|
|
|
|
], function (Util, Constants, Messages, AppConfig, Crypto) {
|
|
|
|
|
var Cursor = {};
|
|
|
|
|
|
|
|
|
|
var DEGRADED = 3; // XXX Number of users before switching to degraded mode
|
|
|
|
|
var DEGRADED = AppConfig.degradedLimit || 8;
|
|
|
|
|
|
|
|
|
|
var convertToUint8 = function (obj) {
|
|
|
|
|
var l = Object.keys(obj).length;
|
|
|
|
@ -50,6 +51,12 @@ define([
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var updateDegraded = function (ctx, wc, chan) {
|
|
|
|
|
var m = wc.members;
|
|
|
|
|
chan.degraded = (m.length-1) >= DEGRADED;
|
|
|
|
|
ctx.emit('DEGRADED', { degraded: chan.degraded }, chan.clients);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var initCursor = function (ctx, obj, client, cb) {
|
|
|
|
|
var channel = obj.channel;
|
|
|
|
|
var secret = obj.secret;
|
|
|
|
@ -92,14 +99,10 @@ define([
|
|
|
|
|
|
|
|
|
|
// ==> And push the new tab to the list
|
|
|
|
|
chan.clients.push(client);
|
|
|
|
|
updateDegraded(ctx, chan.wc, chan);
|
|
|
|
|
return void cb();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var updateDegraded = function (ctx, wc, chan) {
|
|
|
|
|
var m = wc.members;
|
|
|
|
|
chan.degraded = (m.length-1) >= DEGRADED;
|
|
|
|
|
ctx.emit('DEGRADED', { degraded: chan.degraded }, chan.clients);
|
|
|
|
|
};
|
|
|
|
|
var onOpen = function (wc) {
|
|
|
|
|
|
|
|
|
|
ctx.channels[channel] = ctx.channels[channel] || {};
|
|
|
|
|