tribe
Version:
Tribe is a platform for building rich, powerful, highly scalable distributed HTML5 web and mobile systems.
19 lines (16 loc) • 691 B
JavaScript
// this is necessary to ensure messages are only broadcast to clients once
// subscription to multiple facets may produce overlap in subscriptions
// efficiency gains could be had by centralising where messages are
// broadcast from, but this works for now
module.exports = {
annotateEnvelope: function (envelope) {
var recipients = {};
// only attach functions to envelope to ensure nothing is serialised
envelope.hasBeenBroadcastTo = function (clientId) {
return recipients[clientId] === true;
};
envelope.addToBroadcastList = function (clientId) {
recipients[clientId] = true;
};
}
}