Permalink
Browse files

Close GH-3: Call ready and close callbacks only once.

  • Loading branch information...
1 parent 92d4d6f commit 587c2f1b5673a0fd510825c09a7e4e0a403ecaee bitmage committed with contra Feb 22, 2013
Showing with 262 additions and 336 deletions.
  1. +13 −40 dist/Channel.js
  2. +12 −30 dist/Client.js
  3. +0 −1 dist/main.js
  4. +68 −102 example/public/pulsar.js
  5. +3 −3 lib/Channel.coffee
  6. +2 −2 lib/Client.coffee
  7. +2 −2 lib/Server.coffee
  8. +68 −102 pulsar.js
  9. +2 −2 pulsar.min.js
  10. +3 −0 test/mocha.opts
  11. +89 −52 test/server.coffee
View
53 dist/Channel.js
@@ -1,32 +1,22 @@
-// Generated by CoffeeScript 1.4.0
(function() {
var Channel,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __slice = [].slice;
+ __slice = Array.prototype.slice;
Channel = (function() {
function Channel(name, socket) {
this.name = name;
this.socket = socket;
this.runStack = __bind(this.runStack, this);
-
this.use = __bind(this.use, this);
-
this.ready = __bind(this.ready, this);
-
this.removeAllListeners = __bind(this.removeAllListeners, this);
-
this.removeListener = __bind(this.removeListener, this);
-
this.once = __bind(this.once, this);
-
this.addListener = __bind(this.addListener, this);
-
this.emit = __bind(this.emit, this);
-
this.realEmit = __bind(this.realEmit, this);
-
this.events = {};
this.stack = [];
this.joinChannel();
@@ -35,7 +25,6 @@
Channel.prototype.joinChannel = function() {
var _this = this;
if (this.socket) {
- this.joined = false;
this.socket.write({
type: 'join',
channel: this.name
@@ -55,9 +44,7 @@
event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return this.runStack(event, args, function(nargs) {
var l, _i, _len, _ref;
- if (!_this.events[event]) {
- return false;
- }
+ if (!_this.events[event]) return false;
_ref = _this.events[event];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
@@ -113,38 +100,32 @@
Channel.prototype.removeSocketListener = function(listener) {
var l;
- if (!this.listeners) {
- return this;
- }
+ if (!this.listeners) return this;
this.listeners = (function() {
var _i, _len, _ref, _results;
_ref = this.listeners;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
- if (l !== listener) {
- _results.push(l);
- }
+ if (l !== listener) _results.push(l);
}
return _results;
}).call(this);
+ this.emit('unjoin', listener);
+ this.realEmit('unjoin', listener);
return this;
};
Channel.prototype.removeListener = function(event, listener) {
var l;
- if (!this.events[event]) {
- return this;
- }
+ if (!this.events[event]) return this;
this.events[event] = (function() {
var _i, _len, _ref, _results;
_ref = this.events[event];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
- if (l !== listener) {
- _results.push(l);
- }
+ if (l !== listener) _results.push(l);
}
return _results;
}).call(this);
@@ -161,7 +142,7 @@
if (this.joined) {
return fn(this);
} else {
- return this.on('join', function() {
+ return this.once('join', function() {
return fn(_this);
});
}
@@ -175,23 +156,15 @@
Channel.prototype.runStack = function(event, args, cb) {
var emit, idx,
_this = this;
- if (this.stack.length === 0) {
- return cb(args);
- }
- if (event === 'newListener') {
- return cb(args);
- }
+ if (this.stack.length === 0) return cb(args);
+ if (event === 'newListener') return cb(args);
idx = -1;
emit = function() {
var argv, next;
argv = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (argv.length !== 0) {
- args = argv;
- }
+ if (argv.length !== 0) args = argv;
next = _this.stack[++idx];
- if (next == null) {
- return cb(args);
- }
+ if (next == null) return cb(args);
return next.apply(null, [emit, event].concat(__slice.call(args)));
};
emit.apply(null, args);
View
42 dist/Client.js
@@ -1,7 +1,6 @@
-// Generated by CoffeeScript 1.4.0
(function() {
var Channel, client,
- __slice = [].slice;
+ __slice = Array.prototype.slice;
Channel = require('./Channel');
@@ -14,12 +13,11 @@
var _this = this;
this.channels = {};
return this.on("reconnected", function() {
- var chan, name, _i, _len, _ref, _results;
+ var chan, name, _ref, _results;
_ref = _this.channels;
_results = [];
- for (chan = _i = 0, _len = _ref.length; _i < _len; chan = ++_i) {
- name = _ref[chan];
- console.log(name, chan);
+ for (name in _ref) {
+ chan = _ref[name];
_results.push(chan.joinChannel());
}
return _results;
@@ -30,34 +28,18 @@
return (_ref = (_base = this.channels)[name]) != null ? _ref : _base[name] = new Channel(name, this.ssocket);
},
validate: function(socket, msg, done) {
- if (typeof msg !== 'object') {
- return done(false);
- }
- if (typeof msg.type !== 'string') {
- return done(false);
- }
+ if (typeof msg !== 'object') return done(false);
+ if (typeof msg.type !== 'string') return done(false);
switch (msg.type) {
case 'emit':
- if (typeof msg.channel !== 'string') {
- return done(false);
- }
- if (!typeof (this.channels[msg.channel] != null)) {
- return done(false);
- }
- if (typeof msg.event !== 'string') {
- return done(false);
- }
- if (!Array.isArray(msg.args)) {
- return done(false);
- }
+ if (typeof msg.channel !== 'string') return done(false);
+ if (!typeof (this.channels[msg.channel] != null)) return done(false);
+ if (typeof msg.event !== 'string') return done(false);
+ if (!Array.isArray(msg.args)) return done(false);
break;
case 'joined':
- if (typeof msg.channel !== 'string') {
- return done(false);
- }
- if (!typeof (this.channels[msg.channel] != null)) {
- return done(false);
- }
+ if (typeof msg.channel !== 'string') return done(false);
+ if (!typeof (this.channels[msg.channel] != null)) return done(false);
break;
default:
return done(false);
View
1 dist/main.js
@@ -1,4 +1,3 @@
-// Generated by CoffeeScript 1.4.0
(function() {
var ProtoSock, client, server;
View
170 example/public/pulsar.js
@@ -402,7 +402,7 @@ var err = { type: 'error', data: 'parser error' }
*/
exports.encodePacket = function (packet) {
- var encoded = packets[packet.type]
+ var encoded = packets[packet.type];
// data fragment is optional
if (undefined !== packet.data) {
@@ -465,62 +465,61 @@ exports.encodePayload = function (packets) {
/*
* Decodes data when a payload is maybe expected.
*
- * @param {String} data
- * @return {Array} packets
+ * @param {String} data, callback method
+ * @return {NaN}
* @api public
*/
-exports.decodePayload = function (data) {
+exports.decodePayload = function (data, callback) {
+ var packet;
if (data == '') {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
- var packets = []
- , length = ''
- , n, msg, packet
+ var length = ''
+ , n, msg;
for (var i = 0, l = data.length; i < l; i++) {
- var chr = data.charAt(i)
+ var chr = data.charAt(i);
if (':' != chr) {
length += chr;
} else {
if ('' == length || (length != (n = Number(length)))) {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
msg = data.substr(i + 1, n);
if (length != msg.length) {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
if (msg.length) {
packet = exports.decodePacket(msg);
if (err.type == packet.type && err.data == packet.data) {
// parser error in individual packet - ignoring payload
- return [err];
+ return callback(packet, true);
}
- packets.push(packet);
+ return callback(packet, i + n == l - 1);
}
// advance cursor
i += n;
- length = ''
+ length = '';
}
}
if (length != '') {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
- return packets;
};
});
@@ -756,7 +755,6 @@ function Socket(uri, opts){
location.port :
(this.secure ? 443 : 80));
this.query = opts.query || {};
- this.query.uid = rnd();
this.upgrade = false !== opts.upgrade;
this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
this.forceJSONP = !!opts.forceJSONP;
@@ -1210,17 +1208,6 @@ Socket.prototype.filterUpgrades = function (upgrades) {
}
return filteredUpgrades;
};
-
-/**
- * Generates a random uid.
- *
- * @api private
- */
-
-function rnd () {
- return String(Math.random()).substr(5) + String(Math.random()).substr(5);
-}
-
});
require.register("LearnBoost-engine.io-client/lib/transport.js", function(exports, require, module){
@@ -2387,6 +2374,7 @@ JSONPPolling.prototype.doClose = function () {
*/
JSONPPolling.prototype.doPoll = function () {
+ var self = this;
var script = document.createElement('script');
if (this.script) {
@@ -2396,11 +2384,15 @@ JSONPPolling.prototype.doPoll = function () {
script.async = true;
script.src = this.uri();
+ script.onerror = function(e){
+ self.onError('jsonp poll error',e);
+ }
var insertAt = document.getElementsByTagName('script')[0];
insertAt.parentNode.insertBefore(script, insertAt);
this.script = script;
+
if (util.ua.gecko) {
setTimeout(function () {
var iframe = document.createElement('iframe');
@@ -2451,7 +2443,11 @@ JSONPPolling.prototype.doWrite = function (data, fn) {
function initIframe () {
if (self.iframe) {
- self.form.removeChild(self.iframe);
+ try {
+ self.form.removeChild(self.iframe);
+ } catch (e) {
+ self.onError('jsonp polling iframe removal error', e);
+ }
}
try {
@@ -3109,7 +3105,7 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
__extends(Client, _super);
function Client(plugin, options) {
- var eiopts, k, v, _base, _base1, _ref, _ref1;
+ var eiopts, k, v, _base, _base1, _base2, _ref, _ref1, _ref2;
if (options == null) {
options = {};
}
@@ -3137,6 +3133,9 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
if ((_ref1 = (_base1 = this.options).reconnectLimit) == null) {
_base1.reconnectLimit = Infinity;
}
+ if ((_ref2 = (_base2 = this.options).reconnectTimeout) == null) {
+ _base2.reconnectTimeout = Infinity;
+ }
this.isServer = false;
this.isClient = true;
this.isBrowser = typeof window !== "undefined" && window !== null;
@@ -3169,6 +3168,13 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
return this;
};
+ Client.prototype.destroy = function() {
+ this.options.reconnect = false;
+ this.ssocket.disconnect();
+ this.emit("destroyed");
+ return this;
+ };
+
Client.prototype.handleConnection = function() {
this.emit('connected');
return this.connect(this.ssocket);
@@ -3217,7 +3223,7 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
};
Client.prototype.reconnect = function(cb) {
- var attempts, connect, done, err, maxAttempts,
+ var attempts, connect, done, err, maxAttempts, start, timeout,
_this = this;
if (this.ssocket.reconnecting) {
return cb("Already reconnecting");
@@ -3226,10 +3232,13 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
if (this.ssocket.readyState === 'open') {
this.ssocket.disconnect();
}
+ start = Date.now();
maxAttempts = this.options.reconnectLimit;
+ timeout = this.options.reconnectTimeout;
attempts = 0;
done = function() {
_this.ssocket.reconnecting = false;
+ _this.emit("reconnected");
return cb();
};
err = function(e) {
@@ -3244,6 +3253,9 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
if (attempts >= maxAttempts) {
return err("Exceeded max attempts");
}
+ if ((Date.now() - start) > timeout) {
+ return err("Timeout on reconnect");
+ }
attempts++;
_this.ssocket.open();
return setTimeout(connect, getDelay(attempts));
@@ -3261,7 +3273,6 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
});
require.register("pulsar/dist/main.js", function(exports, require, module){
-// Generated by CoffeeScript 1.4.0
(function() {
var ProtoSock, client, server;
@@ -3282,10 +3293,9 @@ require.register("pulsar/dist/main.js", function(exports, require, module){
});
require.register("pulsar/dist/Client.js", function(exports, require, module){
-// Generated by CoffeeScript 1.4.0
(function() {
var Channel, client,
- __slice = [].slice;
+ __slice = Array.prototype.slice;
Channel = require('./Channel');
@@ -3298,12 +3308,11 @@ require.register("pulsar/dist/Client.js", function(exports, require, module){
var _this = this;
this.channels = {};
return this.on("reconnected", function() {
- var chan, name, _i, _len, _ref, _results;
+ var chan, name, _ref, _results;
_ref = _this.channels;
_results = [];
- for (chan = _i = 0, _len = _ref.length; _i < _len; chan = ++_i) {
- name = _ref[chan];
- console.log(name, chan);
+ for (name in _ref) {
+ chan = _ref[name];
_results.push(chan.joinChannel());
}
return _results;
@@ -3314,34 +3323,18 @@ require.register("pulsar/dist/Client.js", function(exports, require, module){
return (_ref = (_base = this.channels)[name]) != null ? _ref : _base[name] = new Channel(name, this.ssocket);
},
validate: function(socket, msg, done) {
- if (typeof msg !== 'object') {
- return done(false);
- }
- if (typeof msg.type !== 'string') {
- return done(false);
- }
+ if (typeof msg !== 'object') return done(false);
+ if (typeof msg.type !== 'string') return done(false);
switch (msg.type) {
case 'emit':
- if (typeof msg.channel !== 'string') {
- return done(false);
- }
- if (!typeof (this.channels[msg.channel] != null)) {
- return done(false);
- }
- if (typeof msg.event !== 'string') {
- return done(false);
- }
- if (!Array.isArray(msg.args)) {
- return done(false);
- }
+ if (typeof msg.channel !== 'string') return done(false);
+ if (!typeof (this.channels[msg.channel] != null)) return done(false);
+ if (typeof msg.event !== 'string') return done(false);
+ if (!Array.isArray(msg.args)) return done(false);
break;
case 'joined':
- if (typeof msg.channel !== 'string') {
- return done(false);
- }
- if (!typeof (this.channels[msg.channel] != null)) {
- return done(false);
- }
+ if (typeof msg.channel !== 'string') return done(false);
+ if (!typeof (this.channels[msg.channel] != null)) return done(false);
break;
default:
return done(false);
@@ -3370,35 +3363,25 @@ require.register("pulsar/dist/Client.js", function(exports, require, module){
});
require.register("pulsar/dist/Channel.js", function(exports, require, module){
-// Generated by CoffeeScript 1.4.0
(function() {
var Channel,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __slice = [].slice;
+ __slice = Array.prototype.slice;
Channel = (function() {
function Channel(name, socket) {
this.name = name;
this.socket = socket;
this.runStack = __bind(this.runStack, this);
-
this.use = __bind(this.use, this);
-
this.ready = __bind(this.ready, this);
-
this.removeAllListeners = __bind(this.removeAllListeners, this);
-
this.removeListener = __bind(this.removeListener, this);
-
this.once = __bind(this.once, this);
-
this.addListener = __bind(this.addListener, this);
-
this.emit = __bind(this.emit, this);
-
this.realEmit = __bind(this.realEmit, this);
-
this.events = {};
this.stack = [];
this.joinChannel();
@@ -3407,7 +3390,6 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
Channel.prototype.joinChannel = function() {
var _this = this;
if (this.socket) {
- this.joined = false;
this.socket.write({
type: 'join',
channel: this.name
@@ -3427,9 +3409,7 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return this.runStack(event, args, function(nargs) {
var l, _i, _len, _ref;
- if (!_this.events[event]) {
- return false;
- }
+ if (!_this.events[event]) return false;
_ref = _this.events[event];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
@@ -3485,38 +3465,32 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
Channel.prototype.removeSocketListener = function(listener) {
var l;
- if (!this.listeners) {
- return this;
- }
+ if (!this.listeners) return this;
this.listeners = (function() {
var _i, _len, _ref, _results;
_ref = this.listeners;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
- if (l !== listener) {
- _results.push(l);
- }
+ if (l !== listener) _results.push(l);
}
return _results;
}).call(this);
+ this.emit('unjoin', listener);
+ this.realEmit('unjoin', listener);
return this;
};
Channel.prototype.removeListener = function(event, listener) {
var l;
- if (!this.events[event]) {
- return this;
- }
+ if (!this.events[event]) return this;
this.events[event] = (function() {
var _i, _len, _ref, _results;
_ref = this.events[event];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
- if (l !== listener) {
- _results.push(l);
- }
+ if (l !== listener) _results.push(l);
}
return _results;
}).call(this);
@@ -3533,7 +3507,7 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
if (this.joined) {
return fn(this);
} else {
- return this.on('join', function() {
+ return this.once('join', function() {
return fn(_this);
});
}
@@ -3547,23 +3521,15 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
Channel.prototype.runStack = function(event, args, cb) {
var emit, idx,
_this = this;
- if (this.stack.length === 0) {
- return cb(args);
- }
- if (event === 'newListener') {
- return cb(args);
- }
+ if (this.stack.length === 0) return cb(args);
+ if (event === 'newListener') return cb(args);
idx = -1;
emit = function() {
var argv, next;
argv = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (argv.length !== 0) {
- args = argv;
- }
+ if (argv.length !== 0) args = argv;
next = _this.stack[++idx];
- if (next == null) {
- return cb(args);
- }
+ if (next == null) return cb(args);
return next.apply(null, [emit, event].concat(__slice.call(args)));
};
emit.apply(null, args);
View
6 lib/Channel.coffee
@@ -3,7 +3,7 @@ class Channel
@events = {}
@stack = []
@joinChannel()
-
+
joinChannel: ->
if @socket
@socket.write
@@ -71,7 +71,7 @@ class Channel
if @joined
fn @
else
- @on 'join', => fn @
+ @once 'join', => fn @
use: (fn) => @stack.push(fn); @
runStack: (event, args, cb) =>
@@ -86,4 +86,4 @@ class Channel
emit args...
return
-module.exports = Channel
+module.exports = Channel
View
4 lib/Client.coffee
@@ -11,7 +11,7 @@ client =
for name, chan of @channels
chan.joinChannel()
- channel: (name) ->
+ channel: (name) ->
@channels[name] ?= new Channel name, @ssocket
validate: (socket, msg, done) ->
@@ -40,4 +40,4 @@ client =
chan.joined = true
chan.realEmit 'join'
-module.exports = client
+module.exports = client
View
4 lib/Server.coffee
@@ -41,11 +41,11 @@ module.exports =
when 'join'
# TODO: Pass an eventemitter instead of socket
chan.listeners.push socket
- socket.on 'close', ->
+ socket.once 'close', ->
chan.removeSocketListener socket
chan.realEmit 'join', socket
socket.write
type: 'joined'
channel: msg.channel
when 'unjoin'
- chan.removeSocketListener socket
+ chan.removeSocketListener socket
View
170 pulsar.js
@@ -402,7 +402,7 @@ var err = { type: 'error', data: 'parser error' }
*/
exports.encodePacket = function (packet) {
- var encoded = packets[packet.type]
+ var encoded = packets[packet.type];
// data fragment is optional
if (undefined !== packet.data) {
@@ -465,62 +465,61 @@ exports.encodePayload = function (packets) {
/*
* Decodes data when a payload is maybe expected.
*
- * @param {String} data
- * @return {Array} packets
+ * @param {String} data, callback method
+ * @return {NaN}
* @api public
*/
-exports.decodePayload = function (data) {
+exports.decodePayload = function (data, callback) {
+ var packet;
if (data == '') {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
- var packets = []
- , length = ''
- , n, msg, packet
+ var length = ''
+ , n, msg;
for (var i = 0, l = data.length; i < l; i++) {
- var chr = data.charAt(i)
+ var chr = data.charAt(i);
if (':' != chr) {
length += chr;
} else {
if ('' == length || (length != (n = Number(length)))) {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
msg = data.substr(i + 1, n);
if (length != msg.length) {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
if (msg.length) {
packet = exports.decodePacket(msg);
if (err.type == packet.type && err.data == packet.data) {
// parser error in individual packet - ignoring payload
- return [err];
+ return callback(packet, true);
}
- packets.push(packet);
+ return callback(packet, i + n == l - 1);
}
// advance cursor
i += n;
- length = ''
+ length = '';
}
}
if (length != '') {
// parser error - ignoring payload
- return [err];
+ return callback(packet, true);
}
- return packets;
};
});
@@ -756,7 +755,6 @@ function Socket(uri, opts){
location.port :
(this.secure ? 443 : 80));
this.query = opts.query || {};
- this.query.uid = rnd();
this.upgrade = false !== opts.upgrade;
this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/';
this.forceJSONP = !!opts.forceJSONP;
@@ -1210,17 +1208,6 @@ Socket.prototype.filterUpgrades = function (upgrades) {
}
return filteredUpgrades;
};
-
-/**
- * Generates a random uid.
- *
- * @api private
- */
-
-function rnd () {
- return String(Math.random()).substr(5) + String(Math.random()).substr(5);
-}
-
});
require.register("LearnBoost-engine.io-client/lib/transport.js", function(exports, require, module){
@@ -2387,6 +2374,7 @@ JSONPPolling.prototype.doClose = function () {
*/
JSONPPolling.prototype.doPoll = function () {
+ var self = this;
var script = document.createElement('script');
if (this.script) {
@@ -2396,11 +2384,15 @@ JSONPPolling.prototype.doPoll = function () {
script.async = true;
script.src = this.uri();
+ script.onerror = function(e){
+ self.onError('jsonp poll error',e);
+ }
var insertAt = document.getElementsByTagName('script')[0];
insertAt.parentNode.insertBefore(script, insertAt);
this.script = script;
+
if (util.ua.gecko) {
setTimeout(function () {
var iframe = document.createElement('iframe');
@@ -2451,7 +2443,11 @@ JSONPPolling.prototype.doWrite = function (data, fn) {
function initIframe () {
if (self.iframe) {
- self.form.removeChild(self.iframe);
+ try {
+ self.form.removeChild(self.iframe);
+ } catch (e) {
+ self.onError('jsonp polling iframe removal error', e);
+ }
}
try {
@@ -3109,7 +3105,7 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
__extends(Client, _super);
function Client(plugin, options) {
- var eiopts, k, v, _base, _base1, _ref, _ref1;
+ var eiopts, k, v, _base, _base1, _base2, _ref, _ref1, _ref2;
if (options == null) {
options = {};
}
@@ -3137,6 +3133,9 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
if ((_ref1 = (_base1 = this.options).reconnectLimit) == null) {
_base1.reconnectLimit = Infinity;
}
+ if ((_ref2 = (_base2 = this.options).reconnectTimeout) == null) {
+ _base2.reconnectTimeout = Infinity;
+ }
this.isServer = false;
this.isClient = true;
this.isBrowser = typeof window !== "undefined" && window !== null;
@@ -3169,6 +3168,13 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
return this;
};
+ Client.prototype.destroy = function() {
+ this.options.reconnect = false;
+ this.ssocket.disconnect();
+ this.emit("destroyed");
+ return this;
+ };
+
Client.prototype.handleConnection = function() {
this.emit('connected');
return this.connect(this.ssocket);
@@ -3217,7 +3223,7 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
};
Client.prototype.reconnect = function(cb) {
- var attempts, connect, done, err, maxAttempts,
+ var attempts, connect, done, err, maxAttempts, start, timeout,
_this = this;
if (this.ssocket.reconnecting) {
return cb("Already reconnecting");
@@ -3226,10 +3232,13 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
if (this.ssocket.readyState === 'open') {
this.ssocket.disconnect();
}
+ start = Date.now();
maxAttempts = this.options.reconnectLimit;
+ timeout = this.options.reconnectTimeout;
attempts = 0;
done = function() {
_this.ssocket.reconnecting = false;
+ _this.emit("reconnected");
return cb();
};
err = function(e) {
@@ -3244,6 +3253,9 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
if (attempts >= maxAttempts) {
return err("Exceeded max attempts");
}
+ if ((Date.now() - start) > timeout) {
+ return err("Timeout on reconnect");
+ }
attempts++;
_this.ssocket.open();
return setTimeout(connect, getDelay(attempts));
@@ -3261,7 +3273,6 @@ require.register("wearefractal-protosock/dist/Client.js", function(exports, requ
});
require.register("pulsar/dist/main.js", function(exports, require, module){
-// Generated by CoffeeScript 1.4.0
(function() {
var ProtoSock, client, server;
@@ -3282,10 +3293,9 @@ require.register("pulsar/dist/main.js", function(exports, require, module){
});
require.register("pulsar/dist/Client.js", function(exports, require, module){
-// Generated by CoffeeScript 1.4.0
(function() {
var Channel, client,
- __slice = [].slice;
+ __slice = Array.prototype.slice;
Channel = require('./Channel');
@@ -3298,12 +3308,11 @@ require.register("pulsar/dist/Client.js", function(exports, require, module){
var _this = this;
this.channels = {};
return this.on("reconnected", function() {
- var chan, name, _i, _len, _ref, _results;
+ var chan, name, _ref, _results;
_ref = _this.channels;
_results = [];
- for (chan = _i = 0, _len = _ref.length; _i < _len; chan = ++_i) {
- name = _ref[chan];
- console.log(name, chan);
+ for (name in _ref) {
+ chan = _ref[name];
_results.push(chan.joinChannel());
}
return _results;
@@ -3314,34 +3323,18 @@ require.register("pulsar/dist/Client.js", function(exports, require, module){
return (_ref = (_base = this.channels)[name]) != null ? _ref : _base[name] = new Channel(name, this.ssocket);
},
validate: function(socket, msg, done) {
- if (typeof msg !== 'object') {
- return done(false);
- }
- if (typeof msg.type !== 'string') {
- return done(false);
- }
+ if (typeof msg !== 'object') return done(false);
+ if (typeof msg.type !== 'string') return done(false);
switch (msg.type) {
case 'emit':
- if (typeof msg.channel !== 'string') {
- return done(false);
- }
- if (!typeof (this.channels[msg.channel] != null)) {
- return done(false);
- }
- if (typeof msg.event !== 'string') {
- return done(false);
- }
- if (!Array.isArray(msg.args)) {
- return done(false);
- }
+ if (typeof msg.channel !== 'string') return done(false);
+ if (!typeof (this.channels[msg.channel] != null)) return done(false);
+ if (typeof msg.event !== 'string') return done(false);
+ if (!Array.isArray(msg.args)) return done(false);
break;
case 'joined':
- if (typeof msg.channel !== 'string') {
- return done(false);
- }
- if (!typeof (this.channels[msg.channel] != null)) {
- return done(false);
- }
+ if (typeof msg.channel !== 'string') return done(false);
+ if (!typeof (this.channels[msg.channel] != null)) return done(false);
break;
default:
return done(false);
@@ -3370,35 +3363,25 @@ require.register("pulsar/dist/Client.js", function(exports, require, module){
});
require.register("pulsar/dist/Channel.js", function(exports, require, module){
-// Generated by CoffeeScript 1.4.0
(function() {
var Channel,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __slice = [].slice;
+ __slice = Array.prototype.slice;
Channel = (function() {
function Channel(name, socket) {
this.name = name;
this.socket = socket;
this.runStack = __bind(this.runStack, this);
-
this.use = __bind(this.use, this);
-
this.ready = __bind(this.ready, this);
-
this.removeAllListeners = __bind(this.removeAllListeners, this);
-
this.removeListener = __bind(this.removeListener, this);
-
this.once = __bind(this.once, this);
-
this.addListener = __bind(this.addListener, this);
-
this.emit = __bind(this.emit, this);
-
this.realEmit = __bind(this.realEmit, this);
-
this.events = {};
this.stack = [];
this.joinChannel();
@@ -3407,7 +3390,6 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
Channel.prototype.joinChannel = function() {
var _this = this;
if (this.socket) {
- this.joined = false;
this.socket.write({
type: 'join',
channel: this.name
@@ -3427,9 +3409,7 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return this.runStack(event, args, function(nargs) {
var l, _i, _len, _ref;
- if (!_this.events[event]) {
- return false;
- }
+ if (!_this.events[event]) return false;
_ref = _this.events[event];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
@@ -3485,38 +3465,32 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
Channel.prototype.removeSocketListener = function(listener) {
var l;
- if (!this.listeners) {
- return this;
- }
+ if (!this.listeners) return this;
this.listeners = (function() {
var _i, _len, _ref, _results;
_ref = this.listeners;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
- if (l !== listener) {
- _results.push(l);
- }
+ if (l !== listener) _results.push(l);
}
return _results;
}).call(this);
+ this.emit('unjoin', listener);
+ this.realEmit('unjoin', listener);
return this;
};
Channel.prototype.removeListener = function(event, listener) {
var l;
- if (!this.events[event]) {
- return this;
- }
+ if (!this.events[event]) return this;
this.events[event] = (function() {
var _i, _len, _ref, _results;
_ref = this.events[event];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
l = _ref[_i];
- if (l !== listener) {
- _results.push(l);
- }
+ if (l !== listener) _results.push(l);
}
return _results;
}).call(this);
@@ -3533,7 +3507,7 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
if (this.joined) {
return fn(this);
} else {
- return this.on('join', function() {
+ return this.once('join', function() {
return fn(_this);
});
}
@@ -3547,23 +3521,15 @@ require.register("pulsar/dist/Channel.js", function(exports, require, module){
Channel.prototype.runStack = function(event, args, cb) {
var emit, idx,
_this = this;
- if (this.stack.length === 0) {
- return cb(args);
- }
- if (event === 'newListener') {
- return cb(args);
- }
+ if (this.stack.length === 0) return cb(args);
+ if (event === 'newListener') return cb(args);
idx = -1;
emit = function() {
var argv, next;
argv = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if (argv.length !== 0) {
- args = argv;
- }
+ if (argv.length !== 0) args = argv;
next = _this.stack[++idx];
- if (next == null) {
- return cb(args);
- }
+ if (next == null) return cb(args);
return next.apply(null, [emit, event].concat(__slice.call(args)));
};
emit.apply(null, args);
View
4 pulsar.min.js
@@ -1,2 +1,2 @@
-(function(){function t(e,o,n){var r=t.resolve(e);if(null==r){n=n||e,o=o||"root";var i=Error('Failed to require "'+n+'" from "'+o+'"');throw i.path=n,i.parent=o,i.require=!0,i}var s=t.modules[r];return s.exports||(s.exports={},s.client=s.component=!0,s.call(this,s.exports,t.relative(r),s)),s.exports}var e=Object.prototype.hasOwnProperty;t.modules={},t.aliases={},t.resolve=function(o){"/"===o.charAt(0)&&(o=o.slice(1));for(var n=o+"/index.js",r=[o,o+".js",o+".json",o+"/index.js",o+"/index.json"],i=0;r.length>i;i++){var o=r[i];if(e.call(t.modules,o))return o}return e.call(t.aliases,n)?t.aliases[n]:void 0},t.normalize=function(t,e){var o=[];if("."!=e.charAt(0))return e;t=t.split("/"),e=e.split("/");for(var n=0;e.length>n;++n)".."==e[n]?t.pop():"."!=e[n]&&""!=e[n]&&o.push(e[n]);return t.concat(o).join("/")},t.register=function(e,o){t.modules[e]=o},t.alias=function(o,n){if(!e.call(t.modules,o))throw Error('Failed to alias "'+o+'", it does not exist');t.aliases[n]=o},t.relative=function(o){function n(t,e){for(var o=t.length;o--;)if(t[o]===e)return o;return-1}function r(e){var n=r.resolve(e);return t(n,o,e)}var i=t.normalize(o,"..");return r.resolve=function(e){var r=e.charAt(0);if("/"==r)return e.slice(1);if("."==r)return t.normalize(i,e);var s=o.split("/"),a=n(s,"deps")+1;return a||(a=0),e=s.slice(0,a+1).join("/")+"/deps/"+e},r.exists=function(o){return e.call(t.modules,r.resolve(o))},r},t.register("component-emitter/index.js",function(t,e,o){function n(t){return t?r(t):void 0}function r(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}o.exports=n,n.prototype.on=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},n.prototype.once=function(t,e){function o(){n.off(t,o),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},e._off=o,this.on(t,o),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=function(t,e){this._callbacks=this._callbacks||{};var o=this._callbacks[t];if(!o)return this;if(1==arguments.length)return delete this._callbacks[t],this;var n=o.indexOf(e._off||e);return~n&&o.splice(n,1),this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),o=this._callbacks[t];if(o){o=o.slice(0);for(var n=0,r=o.length;r>n;++n)o[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}}),t.register("LearnBoost-engine.io-protocol/lib/index.js",function(t,e){var o=e("./keys"),n=t.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},r=o(n),i={type:"error",data:"parser error"};t.encodePacket=function(t){var e=n[t.type];return void 0!==t.data&&(e+=t.data+""),""+e},t.decodePacket=function(t){var e=t.charAt(0);return Number(e)==e&&r[e]?t.length>1?{type:r[e],data:t.substring(1)}:{type:r[e]}:i},t.encodePayload=function(e){if(!e.length)return"0:";for(var o,n="",r=0,i=e.length;i>r;r++)o=t.encodePacket(e[r]),n+=o.length+":"+o;return n},t.decodePayload=function(e){if(""==e)return[i];for(var o,n,r,s=[],a="",c=0,p=e.length;p>c;c++){var l=e.charAt(c);if(":"!=l)a+=l;else{if(""==a||a!=(o=Number(a)))return[i];if(n=e.substr(c+1,o),a!=n.length)return[i];if(n.length){if(r=t.decodePacket(n),i.type==r.type&&i.data==r.data)return[i];s.push(r)}c+=o,a=""}}return""!=a?[i]:s}}),t.register("LearnBoost-engine.io-protocol/lib/keys.js",function(t,e,o){o.exports=Object.keys||function(t){var e=[],o=Object.prototype.hasOwnProperty;for(var n in t)o.call(t,n)&&e.push(n);return e}}),t.register("visionmedia-debug/index.js",function(t,e,o){o.exports="undefined"==typeof window?e("./lib/debug"):e("./debug")}),t.register("visionmedia-debug/debug.js",function(t,e,o){function n(t){return n.enabled(t)?function(e){var o=new Date,r=o-(n[t]||o);n[t]=o,e=t+" "+e+" +"+n.humanize(r),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}o.exports=n,n.names=[],n.skips=[],n.enable=function(t){try{localStorage.debug=t}catch(e){}for(var o=(t||"").split(/[\s,]+/),r=o.length,i=0;r>i;i++)t=o[i].replace("*",".*?"),"-"===t[0]?n.skips.push(RegExp("^"+t.substr(1)+"$")):n.names.push(RegExp("^"+t+"$"))},n.disable=function(){n.enable("")},n.humanize=function(t){var e=1e3,o=6e4,n=60*o;return t>=n?(t/n).toFixed(1)+"h":t>=o?(t/o).toFixed(1)+"m":t>=e?(0|t/e)+"s":t+"ms"},n.enabled=function(t){for(var e=0,o=n.skips.length;o>e;e++)if(n.skips[e].test(t))return!1;for(var e=0,o=n.names.length;o>e;e++)if(n.names[e].test(t))return!0;return!1},window.localStorage&&n.enable(localStorage.debug)}),t.register("LearnBoost-engine.io-client/lib/index.js",function(t,e,o){o.exports=e("./socket"),o.exports.parser=e("engine.io-parser")}),t.register("LearnBoost-engine.io-client/lib/socket.js",function(t,e,o){function n(t,e){if(!(this instanceof n))return new n(t,e);if(e=e||{},"object"==typeof t&&(e=t,t=null),t&&(t=s.parseUri(t),e.host=t.host,e.secure="https"==t.protocol||"wss"==t.protocol,e.port=t.port),this.secure=null!=e.secure?e.secure:l.location&&"https:"==location.protocol,e.host){var o=e.host.split(":");e.hostname=o.shift(),o.length&&(e.port=o.pop())}this.hostname=e.hostname||(l.location?location.hostname:"localhost"),this.port=e.port||(l.location&&location.port?location.port:this.secure?443:80),this.query=e.query||{},this.query.uid=i(),this.upgrade=!1!==e.upgrade,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.timestampParam=e.timestampParam||"t",this.timestampRequests=!!e.timestampRequests,this.flashPath=e.flashPath||"",this.transports=e.transports||["polling","websocket","flashsocket"],this.readyState="",this.writeBuffer=[],this.policyPort=e.policyPort||843,this.open(),n.sockets.push(this),n.sockets.evs.emit("add",this)}function r(t){var e={};for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);return e}function i(){return(Math.random()+"").substr(5)+(Math.random()+"").substr(5)}var s=e("./util"),a=e("./transports"),c=e("./emitter"),p=e("debug")("engine-client:socket");o.exports=n;var l=s.global();c(n.prototype),n.protocol=1,n.sockets=[],n.sockets.evs=new c,n.Socket=n,n.Transport=e("./transport"),n.Emitter=e("./emitter"),n.transports=e("./transports"),n.util=e("./util"),n.parser=e("engine.io-parser"),n.prototype.createTransport=function(t){p('creating transport "%s"',t);var e=r(this.query);e.transport=t,this.id&&(e.sid=this.id);var o=new a[t]({hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:e,forceJSONP:this.forceJSONP,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,flashPath:this.flashPath,policyPort:this.policyPort});return o},n.prototype.open=function(){this.readyState="opening";var t=this.createTransport(this.transports[0]);t.open(),this.setTransport(t)},n.prototype.setTransport=function(t){var e=this;this.transport&&(p("clearing existing transport"),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.flush()}).on("packet",function(t){e.onPacket(t)}).on("error",function(t){e.onError(t)}).on("close",function(){e.onClose("transport close")})},n.prototype.probe=function(t){function e(e){if(!n){n=!0;var i=Error("probe error: "+e);i.transport=o.name,o.close(),o=null,p('probe transport "%s" failed because of error: %s',t,e),r.emit("error",i)}}p('probing transport "%s"',t);var o=this.createTransport(t,{probe:1}),n=!1,r=this;o.once("open",function(){n||(p('probe transport "%s" opened',t),o.send([{type:"ping",data:"probe"}]),o.once("packet",function(i){if(!n)if("pong"==i.type&&"probe"==i.data)p('probe transport "%s" pong',t),r.upgrading=!0,r.emit("upgrading",o),p('pausing current transport "%s"',r.transport.name),r.transport.pause(function(){n||"closed"!=r.readyState&&"closing"!=r.readyState&&(p("changing transport and sending upgrade packet"),o.removeListener("error",e),r.emit("upgrade",o),r.setTransport(o),o.send([{type:"upgrade"}]),o=null,r.upgrading=!1,r.flush())});else{p('probe transport "%s" failed',t);var s=Error("probe error");s.transport=o.name,r.emit("error",s)}}))}),o.once("error",e),o.open(),this.once("close",function(){o&&(p("socket closed prematurely - aborting probe"),n=!0,o.close(),o=null)}),this.once("upgrading",function(t){o&&t.name!=o.name&&(p('"%s" works - aborting "%s"',t.name,o.name),o.close(),o=null)})},n.prototype.onOpen=function(){if(p("socket open"),this.readyState="open",this.emit("open"),this.onopen&&this.onopen.call(this),this.flush(),"open"==this.readyState&&this.upgrade&&this.transport.pause){p("starting upgrade probes");for(var t=0,e=this.upgrades.length;e>t;t++)this.probe(this.upgrades[t])}},n.prototype.onPacket=function(t){if("opening"==this.readyState||"open"==this.readyState)switch(p('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(s.parseJSON(t.data));break;case"pong":this.ping();break;case"error":var e=Error("server error");e.code=t.data,this.emit("error",e);break;case"message":this.emit("data",t.data),this.emit("message",t.data);var o={data:t.data};o.toString=function(){return t.data},this.onmessage&&this.onmessage.call(this,o)}else p('packet received with socket readyState "%s"',this.readyState)},n.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),this.ping(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat)},n.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout(function(){"closed"!=e.readyState&&e.onClose("ping timeout")},t||e.pingInterval+e.pingTimeout)},n.prototype.ping=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout(function(){p("writing ping packet - expecting pong within %sms",t.pingTimeout),t.sendPacket("ping"),t.onHeartbeat(t.pingTimeout)},t.pingInterval)},n.prototype.flush=function(){"closed"!=this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(p("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.writeBuffer=[])},n.prototype.write=n.prototype.send=function(t){return this.sendPacket("message",t),this},n.prototype.sendPacket=function(t,e){var o={type:t,data:e};this.emit("packetCreate",o),this.writeBuffer.push(o),this.flush()},n.prototype.close=function(){return("opening"==this.readyState||"open"==this.readyState)&&(this.onClose("forced close"),p("socket closing - telling transport to close"),this.transport.close(),this.transport.removeAllListeners()),this},n.prototype.onError=function(t){p("socket error %j",t),this.emit("error",t),this.onClose("transport error",t)},n.prototype.onClose=function(t,e){("opening"==this.readyState||"open"==this.readyState)&&(p('socket close with reason: "%s"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.readyState="closed",this.emit("close",t,e),this.onclose&&this.onclose.call(this),this.id=null)},n.prototype.filterUpgrades=function(t){for(var e=[],o=0,n=t.length;n>o;o++)~this.transports.indexOf(t[o])&&e.push(t[o]);return e}}),t.register("LearnBoost-engine.io-client/lib/transport.js",function(t,e,o){function n(t){this.path=t.path,this.hostname=t.hostname,this.port=t.port,this.secure=t.secure,this.query=t.query,this.timestampParam=t.timestampParam,this.timestampRequests=t.timestampRequests,this.readyState=""}var r=(e("./util"),e("engine.io-parser")),i=e("./emitter");o.exports=n,i(n.prototype),n.prototype.onError=function(t,e){var o=Error(t);return o.type="TransportError",o.description=e,this.emit("error",o),this},n.prototype.open=function(){return("closed"==this.readyState||""==this.readyState)&&(this.readyState="opening",this.doOpen()),this},n.prototype.close=function(){return("opening"==this.readyState||"open"==this.readyState)&&(this.doClose(),this.onClose()),this},n.prototype.send=function(t){if("open"!=this.readyState)throw Error("Transport not open");this.write(t)},n.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},n.prototype.onData=function(t){this.onPacket(r.decodePacket(t))},n.prototype.onPacket=function(t){this.emit("packet",t)},n.prototype.onClose=function(){this.readyState="closed",this.emit("close")}}),t.register("LearnBoost-engine.io-client/lib/emitter.js",function(t,e,o){var n;try{n=e("emitter")}catch(r){n=e("emitter-component")}o.exports=n,n.prototype.addEventListener=n.prototype.on,n.prototype.removeEventListener=n.prototype.off,n.prototype.removeListener=n.prototype.off,n.prototype.removeAllListeners=function(){this._callbacks={}}}),t.register("LearnBoost-engine.io-client/lib/util.js",function(t,e){var o=!1;t.global=function(){return"undefined"!=typeof window?window:global},t.inherits=function(t,e){function o(){}o.prototype=e.prototype,t.prototype=new o},t.keys=Object.keys||function(t){var e=[],o=Object.prototype.hasOwnProperty;for(var n in t)o.call(t,n)&&e.push(n);return e},t.on=function(t,e,o,n){t.attachEvent?t.attachEvent("on"+e,o):t.addEventListener&&t.addEventListener(e,o,n)},t.load=function(e){var n=t.global();return n.document&&"complete"===document.readyState||o?e():(t.on(n,"load",e,!1),void 0)},"undefined"!=typeof window&&t.load(function(){o=!0}),t.defer=function(e){return t.ua.webkit&&"undefined"==typeof importScripts?(t.load(function(){setTimeout(e,100)}),void 0):e()};var n=/^[\],:{}\s]*$/,r=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,i=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,s=/(?:^|:|,)(?:\s*\[)+/g,a=/^\s+/,c=/\s+$/;t.parseJSON=function(e){var o=t.global();return"string"==typeof e&&e?(e=e.replace(a,"").replace(c,""),o.JSON&&JSON.parse?JSON.parse(e):n.test(e.replace(r,"@").replace(i,"]").replace(s,""))?Function("return "+e)():void 0):null},t.ua={},t.ua.hasCORS="undefined"!=typeof XMLHttpRequest&&function(){try{var t=new XMLHttpRequest}catch(e){return!1}return void 0!=t.withCredentials}(),t.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent),t.ua.gecko="undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent),t.ua.android="undefined"!=typeof navigator&&/android/i.test(navigator.userAgent),t.ua.ios="undefined"!=typeof navigator&&/^(iPad|iPhone|iPod)$/.test(navigator.platform),t.ua.ios6=t.ua.ios&&/OS 6_/.test(navigator.userAgent),t.request=function(o){if("undefined"==typeof window){var n=e("xmlhttprequest").XMLHttpRequest;return new n}if(o&&"undefined"!=typeof XDomainRequest&&!t.ua.hasCORS)return new XDomainRequest;try{if("undefined"!=typeof XMLHttpRequest&&(!o||t.ua.hasCORS))return new XMLHttpRequest}catch(r){}if(!o)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(r){}};var p=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,l=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.parseUri=function(t){for(var e=p.exec(t||""),o={},n=14;n--;)o[l[n]]=e[n]||"";return o},t.qs=function(t){var e="";for(var o in t)t.hasOwnProperty(o)&&(e.length&&(e+="&"),e+=o+"="+encodeURIComponent(t[o]));return e}}),t.register("LearnBoost-engine.io-client/lib/transports/index.js",function(t,e){function o(t){var e,o=!1,i=!1;if(c.location){var s="https:"==location.protocol,p=location.port;Number(p)!=p&&(p=s?443:80),o=t.host!=location.hostname||p!=t.port,i=t.secure!=s}return e=a.request(o),i&&c.XDomainRequest&&e instanceof c.XDomainRequest?new r(t):e&&!t.forceJSONP?new n(t):new r(t)}var n=e("./polling-xhr"),r=e("./polling-jsonp"),i=e("./websocket"),s=e("./flashsocket"),a=e("../util");t.polling=o,t.websocket=i,t.flashsocket=s;var c=a.global()}),t.register("LearnBoost-engine.io-client/lib/transports/polling.js",function(t,e,o){function n(t){r.call(this,t)}var r=e("../transport"),i=e("../util"),s=e("engine.io-parser"),a=e("debug")("engine.io-client:polling");o.exports=n;var c=i.global();i.inherits(n,r),n.prototype.name="polling",n.prototype.doOpen=function(){this.poll()},n.prototype.pause=function(t){function e(){a("paused"),o.readyState="paused",t()}var o=this;if(this.readyState="pausing",this.polling||!this.writable){var n=0;this.polling&&(a("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){a("pre-pause polling complete"),--n||e()})),this.writable||(a("we are currently writing - waiting to pause"),n++,this.once("drain",function(){a("pre-pause writing complete"),--n||e()}))}else e()},n.prototype.poll=function(){a("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},n.prototype.onData=function(t){a("polling got data %s",t);for(var e=s.decodePayload(t),o=0,n=e.length;n>o;o++){if("opening"==this.readyState&&this.onOpen(),"close"==e[o].type)return this.onClose(),void 0;this.onPacket(e[o])}this.polling=!1,this.emit("pollComplete"),"open"==this.readyState?this.poll():a('ignoring poll - transport state "%s"',this.readyState)},n.prototype.doClose=function(){a("sending close packet"),this.send([{type:"close"}])},n.prototype.write=function(t){var e=this;this.writable=!1,this.doWrite(s.encodePayload(t),function(){e.writable=!0,e.emit("drain")})},n.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",o="";return(c.ActiveXObject||i.ua.android||i.ua.ios6||this.timestampRequests)&&(t[this.timestampParam]=+new Date),t=i.qs(t),this.port&&("https"==e&&443!=this.port||"http"==e&&80!=this.port)&&(o=":"+this.port),t.length&&(t="?"+t),e+"://"+this.hostname+o+this.path+t}}),t.register("LearnBoost-engine.io-client/lib/transports/polling-xhr.js",function(t,e,o){function n(){}function r(t){s.call(this,t),l.location&&(this.xd=t.host!=l.location.hostname||l.location.port!=t.port)}function i(t){this.method=t.method||"GET",this.uri=t.uri,this.xd=!!t.xd,this.async=!1!==t.async,this.data=void 0!=t.data?t.data:null,this.create()}var s=e("./polling"),a=e("../util"),c=e("../emitter"),p=e("debug")("engine.io-client:polling-xhr");o.exports=r,o.exports.Request=i;var l=a.global(),u=l[["Active"].concat("Object").join("X")];a.inherits(r,s),r.prototype.doOpen=function(){var t=this;a.defer(function(){s.prototype.doOpen.call(t)})},r.prototype.request=function(t){return t=t||{},t.uri=this.uri(),t.xd=this.xd,new i(t)},r.prototype.doWrite=function(t,e){var o=this.request({method:"POST",data:t}),n=this;o.on("success",e),o.on("error",function(t){n.onError("xhr post error",t)}),this.sendXhr=o},r.prototype.doPoll=function(){p("xhr poll");var t=this.request(),e=this;t.on("data",function(t){e.onData(t)}),t.on("error",function(t){e.onError("xhr poll error",t)}),this.pollXhr=t},c(i.prototype),i.prototype.create=function(){var t=this.xhr=a.request(this.xd),e=this;if(t.open(this.method,this.uri,this.async),"POST"==this.method)try{t.setRequestHeader?t.setRequestHeader("Content-type","text/plain;charset=UTF-8"):t.contentType="text/plain"}catch(o){}this.xd&&l.XDomainRequest&&t instanceof XDomainRequest?(t.onerror=function(t){e.onError(t)},t.onload=function(){e.onData(t.responseText)},t.onprogress=n):("withCredentials"in t&&(t.withCredentials=!0),t.onreadystatechange=function(){var o;try{if(4!=t.readyState)return;200==t.status||1223==t.status?o=t.responseText:e.onError(t.status)}catch(n){e.onError(n)}void 0!==o&&e.onData(o)}),p("sending xhr with url %s | data %s",this.uri,this.data),t.send(this.data),u&&(this.index=i.requestsCount++,i.requests[this.index]=this)},i.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},i.prototype.onData=function(t){this.emit("data",t),this.onSuccess()},i.prototype.onError=function(t){this.emit("error",t),this.cleanup()},i.prototype.cleanup=function(){this.xhr.onreadystatechange=n,this.xhr.onload=this.xhr.onerror=n;try{this.xhr.abort()}catch(t){}u&&delete i.requests[this.index],this.xhr=null},i.prototype.abort=function(){this.cleanup()},u&&(i.requestsCount=0,i.requests={},l.attachEvent("onunload",function(){for(var t in i.requests)i.requests.hasOwnProperty(t)&&i.requests[t].abort()}))}),t.register("LearnBoost-engine.io-client/lib/transports/polling-jsonp.js",function(t,e,o){function n(t){r.call(this,t),s||(a.___eio||(a.___eio=[]),s=a.___eio),this.index=s.length;var e=this;s.push(function(t){e.onData(t)}),this.query.j=this.index}var r=e("./polling"),i=e("../util");o.exports=n;var s,a=i.global(),c=/\n/g;i.inherits(n,r),n.prototype.doOpen=function(){var t=this;i.defer(function(){r.prototype.doOpen.call(t)})},n.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null),r.prototype.doClose.call(this)},n.prototype.doPoll=function(){var t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri();var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e),this.script=t,i.ua.gecko&&setTimeout(function(){var t=document.createElement("iframe");document.body.appendChild(t),document.body.removeChild(t)},100)},n.prototype.doWrite=function(t,e){function o(){n(),e()}function n(){r.iframe&&r.form.removeChild(r.iframe);try{var t='<iframe src="javascript:0" name="'+r.iframeId+'">';i=document.createElement(t)}catch(e){i=document.createElement("iframe"),i.name=r.iframeId,i.src="javascript:0"}i.id=r.iframeId,r.form.appendChild(i),r.iframe=i}var r=this;if(!this.form){var i,s=document.createElement("form"),a=document.createElement("textarea"),p=this.iframeId="eio_iframe_"+this.index;s.className="socketio",s.style.position="absolute",s.style.top="-1000px",s.style.left="-1000px",s.target=p,s.method="POST",s.setAttribute("accept-charset","utf-8"),a.name="d",s.appendChild(a),document.body.appendChild(s),this.form=s,this.area=a}this.form.action=this.uri(),n(),this.area.value=t.replace(c,"\\n");try{this.form.submit()}catch(l){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"==r.iframe.readyState&&o()}:this.iframe.onload=o}}),t.register("LearnBoost-engine.io-client/lib/transports/websocket.js",function(t,e,o){function n(t){i.call(this,t)}function r(){return"undefined"==typeof window?e("ws"):c.WebSocket||c.MozWebSocket}var i=e("../transport"),s=e("engine.io-parser"),a=e("../util");e("debug")("engine.io-client:websocket"),o.exports=n;var c=a.global();a.inherits(n,i),n.prototype.name="websocket",n.prototype.doOpen=function(){if(this.check()){var t=this;this.socket=new(r())(this.uri()),this.socket.onopen=function(){t.onOpen()},this.socket.onclose=function(){t.onClose()},this.socket.onmessage=function(e){t.onData(e.data)},this.socket.onerror=function(e){t.onError("websocket error",e)}}},n.prototype.write=function(t){for(var e=0,o=t.length;o>e;e++)this.socket.send(s.encodePacket(t[e]))},n.prototype.doClose=function(){this.socket!==void 0&&this.socket.close()},n.prototype.uri=function(){var t=this.query||{},e=this.secure?"wss":"ws",o="";return this.port&&("wss"==e&&443!=this.port||"ws"==e&&80!=this.port)&&(o=":"+this.port),this.timestampRequests&&(t[this.timestampParam]=+new Date),t=a.qs(t),t.length&&(t="?"+t),e+"://"+this.hostname+o+this.path+t},n.prototype.check=function(){var t=r();return!(!t||"__initialize"in t&&this.name===n.prototype.name)}}),t.register("LearnBoost-engine.io-client/lib/transports/flashsocket.js",function(t,e,o){function n(t){s.call(this,t),this.flashPath=t.flashPath,this.policyPort=t.policyPort}function r(t,e){if(u[t])return e();var o=document.createElement("script"),n=!1;c('loading "%s"',t),o.onload=o.onreadystatechange=function(){if(!n&&!u[t]){var r=o.readyState;r&&"loaded"!=r&&"complete"!=r||(c('loaded "%s"',t),o.onload=o.onreadystatechange=null,n=!0,u[t]=!0,e())}},o.async=1,o.src=t;var r=document.getElementsByTagName("head")[0];r.insertBefore(o,r.firstChild)}function i(t,e){function o(n){return t[n]?(r(t[n],function(){o(++n)}),void 0):e()}o(0)}var s=e("./websocket"),a=e("../util"),c=e("debug")("engine.io-client:flashsocket");o.exports=n;var p=a.global(),l=p[["Active"].concat("Object").join("X")];a.inherits(n,s),n.prototype.name="flashsocket",n.prototype.doOpen=function(){function t(t){return function(){var e=Array.prototype.join.call(arguments," ");c("[websocketjs %s] %s",t,e)}}if(this.check()){WEB_SOCKET_LOGGER={log:t("debug"),error:t("error")},WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR=!0,WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0,"undefined"==typeof WEB_SOCKET_SWF_LOCATION&&(WEB_SOCKET_SWF_LOCATION=this.flashPath+"WebSocketMainInsecure.swf");var e=[this.flashPath+"web_socket.js"];"undefined"==typeof swfobject&&e.unshift(this.flashPath+"swfobject.js");var o=this;i(e,function(){o.ready(function(){WebSocket.__addTask(function(){s.prototype.doOpen.call(o)})})})}},n.prototype.doClose=function(){if(this.socket){var t=this;WebSocket.__addTask(function(){s.prototype.doClose.call(t)})}},n.prototype.write=function(){var t=this,e=arguments;WebSocket.__addTask(function(){s.prototype.write.apply(t,e)})},n.prototype.ready=function(t){function e(){n.loaded||(843!=o.policyPort&&WebSocket.loadFlashPolicyFile("xmlsocket://"+o.host+":"+o.policyPort),WebSocket.__initialize(),n.loaded=!0),t.call(o)}if("undefined"!=typeof WebSocket&&"__initialize"in WebSocket&&swfobject&&!(10>swfobject.getFlashPlayerVersion().major)){var o=this;return document.body?e():(a.load(e),void 0)}},n.prototype.check=function(){if("undefined"==typeof window)return!1;if("undefined"!=typeof WebSocket&&!("__initialize"in WebSocket))return!1;if(l){var t=null;try{t=new l("ShockwaveFlash.ShockwaveFlash")}catch(e){}if(t)return!0}else for(var o=0,n=navigator.plugins.length;n>o;o++)for(var r=0,i=navigator.plugins[o].length;i>r;r++)if("Shockwave Flash"==navigator.plugins[o][r].description)return!0;return!1};var u={}}),t.register("wearefractal-protosock/dist/main.js",function(t,e,o){(function(){var t,n,r,i,s,a;a=e("./util"),t=e("./Client"),r=e("./defaultClient"),s={createClientWrapper:function(t){return function(e){return s.createClient(t,e)}},createClient:function(e,o){var n;return n=a.mergePlugins(r,e),new t(n,o)}},("undefined"==typeof window||null===window)&&(n=e("./Server"),i=e("./defaultServer"),e("http").globalAgent.maxSockets=999,s.createServer=function(t,e,o){var r;return r=a.mergePlugins(i,e),new n(t,r,o)},s.createServerWrapper=function(t){return function(e,o){return s.createServer(e,t,o)}}),o.exports=s}).call(this)}),t.register("wearefractal-protosock/dist/Socket.js",function(t,e,o){(function(){var t;t={write:function(t){var e=this;return this.parent.outbound(this,t,function(t){return e.send(t)}),this},disconnect:function(t){return this.close(t),this}},o.exports=t}).call(this)}),t.register("wearefractal-protosock/dist/util.js",function(t,e,o){(function(){var t,n,r={}.hasOwnProperty,i=function(t,e){function o(){this.constructor=t}for(var n in e)r.call(e,n)&&(t[n]=e[n]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},s=[].slice;t=e("./Socket"),n={extendSocket:function(e){return i(e.prototype,t)},mergePlugins:function(){var t,e,o,r,i,a,c;for(t=arguments.length>=1?s.call(arguments,0):[],o={},a=0,c=t.length;c>a;a++){r=t[a];for(e in r)i=r[e],o[e]="object"==typeof i&&"server"!==e?n.mergePlugins(o[e],i):i}return o}},o.exports=n}).call(this)}),t.register("wearefractal-protosock/dist/defaultClient.js",function(t,e,o){(function(){var t;t={options:{},start:function(){},inbound:function(t,e,o){var n;try{n=JSON.parse(e)}catch(r){this.error(t,r)}o(n)},outbound:function(t,e,o){var n;try{n=JSON.stringify(e)}catch(r){this.error(t,r)}o(n)},validate:function(t,e,o){return o(!0)},invalid:function(){},connect:function(){},message:function(){},error:function(){},close:function(){}},"undefined"!=typeof window&&null!==window&&(t.options={host:window.location.hostname,port:window.location.port.length>0?parseInt(window.location.port):80,secure:"https:"===window.location.protocol},t.options.secure&&(t.options.port=443)),o.exports=t}).call(this)}),t.register("wearefractal-protosock/dist/Client.js",function(t,e,o){(function(){var t,n,r,i,s,a=function(t,e){return function(){return t.apply(e,arguments)}},c={}.hasOwnProperty,p=function(t,e){function o(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t};s=e("./util"),"undefined"!=typeof window&&null!==window?(r=e("engine.io"),n=e("emitter")):(r=e("engine.io-client"),n=e("events").EventEmitter),s.extendSocket(r.Socket),i=function(t){return t>10?15e3:t>5?5e3:t>3?1e3:1e3},t=function(t){function e(t,e){var o,n,i,s,c,p,l;null==e&&(e={}),this.reconnect=a(this.reconnect,this),this.handleClose=a(this.handleClose,this),this.handleError=a(this.handleError,this),this.handleMessage=a(this.handleMessage,this),this.handleConnection=a(this.handleConnection,this);for(n in t)i=t[n],this[n]=i;for(n in e)i=e[n],this.options[n]=i;null==(p=(s=this.options).reconnect)&&(s.reconnect=!0),null==(l=(c=this.options).reconnectLimit)&&(c.reconnectLimit=1/0),this.isServer=!1,this.isClient=!0,this.isBrowser="undefined"!=typeof window&&null!==window,o={host:this.options.host,port:this.options.port,secure:this.options.secure,path:"/"+this.options.namespace,resource:this.options.resource,transports:this.options.transports,upgrade:this.options.upgrade,flashPath:this.options.flashPath,policyPort:this.options.policyPort,forceJSONP:this.options.forceJSONP,forceBust:this.options.forceBust,debug:this.options.debug},this.ssocket=new r(o),this.ssocket.parent=this,this.ssocket.once("open",this.handleConnection),this.ssocket.on("error",this.handleError),this.ssocket.on("message",this.handleMessage),this.ssocket.on("close",this.handleClose),this.start()}return p(e,t),e.prototype.disconnect=function(){return this.ssocket.disconnect(),this},e.prototype.handleConnection=function(){return this.emit("connected"),this.connect(this.ssocket)},e.prototype.handleMessage=function(t){var e=this;return this.emit("inbound",this.ssocket,t),this.inbound(this.ssocket,t,function(t){return e.validate(e.ssocket,t,function(o){return o?(e.emit("message",e.ssocket,t),e.message(e.ssocket,t)):(e.emit("invalid",e.ssocket,t),e.invalid(e.ssocket,t))})})},e.prototype.handleError=function(t){return"string"==typeof t&&(t=Error(t)),this.error(this.ssocket,t)},e.prototype.handleClose=function(t){var e=this;if(!this.ssocket.reconnecting)return this.options.reconnect?this.reconnect(function(o){return null!=o?(e.emit("close",e.ssocket,t),e.close(e.ssocket,t)):void 0}):(this.emit("close",this.ssocket,t),this.close(this.ssocket,t))},e.prototype.reconnect=function(t){var e,o,n,r,s,a=this;return this.ssocket.reconnecting?t("Already reconnecting"):(this.ssocket.reconnecting=!0,"open"===this.ssocket.readyState&&this.ssocket.disconnect(),s=this.options.reconnectLimit,e=0,n=function(){return a.ssocket.reconnecting=!1,t()},r=function(e){return a.ssocket.reconnecting=!1,t(e)},this.ssocket.once("open",n),o=function(){return a.ssocket.reconnecting?e>=s?r("Exceeded max attempts"):(e++,a.ssocket.open(),setTimeout(o,i(e))):void 0},setTimeout(o,i(e)))},e}(n),o.exports=t}).call(this)}),t.register("pulsar/dist/main.js",function(t,e,o){(function(){var t,n,r;t=e("protosock"),n=e("./Client"),o.exports={createClient:t.createClientWrapper(n)},("undefined"==typeof window||null===window)&&(r=e("./Server"),o.exports.createServer=t.createServerWrapper(r))}).call(this)}),t.register("pulsar/dist/Client.js",function(t,e,o){(function(){var t,n,r=[].slice;t=e("./Channel"),n={options:{namespace:"Pulsar",resource:"default"},start:function(){var t=this;return this.channels={},this.on("reconnected",function(){var e,o,n,r,i,s;for(i=t.channels,s=[],e=n=0,r=i.length;r>n;e=++n)o=i[e],console.log(o,e),s.push(e.joinChannel());return s})},channel:function(e){var o,n;return null!=(n=(o=this.channels)[e])?n:o[e]=new t(e,this.ssocket)},validate:function(t,e,o){if("object"!=typeof e)return o(!1);
-if("string"!=typeof e.type)return o(!1);switch(e.type){case"emit":if("string"!=typeof e.channel)return o(!1);if("string"!=typeof e.event)return o(!1);if(!Array.isArray(e.args))return o(!1);break;case"joined":if("string"!=typeof e.channel)return o(!1);break;default:return o(!1)}return o(!0)},error:function(t,e){return this.emit("error",e,t)},message:function(t,e){var o;switch(o=this.channels[e.channel],e.type){case"emit":return o.realEmit.apply(o,[e.event].concat(r.call(e.args)));case"joined":return o.joined=!0,o.realEmit("join")}}},o.exports=n}).call(this)}),t.register("pulsar/dist/Channel.js",function(t,e,o){(function(){var t,e=function(t,e){return function(){return t.apply(e,arguments)}},n=[].slice;t=function(){function t(t,o){this.name=t,this.socket=o,this.runStack=e(this.runStack,this),this.use=e(this.use,this),this.ready=e(this.ready,this),this.removeAllListeners=e(this.removeAllListeners,this),this.removeListener=e(this.removeListener,this),this.once=e(this.once,this),this.addListener=e(this.addListener,this),this.emit=e(this.emit,this),this.realEmit=e(this.realEmit,this),this.events={},this.stack=[],this.joinChannel()}return t.prototype.joinChannel=function(){var t=this;return this.socket?(this.joined=!1,this.socket.write({type:"join",channel:this.name}),this.socket.once("close",function(){return t.joined=!1})):(this.joined=!0,this.listeners=[])},t.prototype.realEmit=function(){var t,e,o=this;return e=arguments[0],t=arguments.length>=2?n.call(arguments,1):[],this.runStack(e,t,function(t){var n,r,i,s;if(!o.events[e])return!1;for(s=o.events[e],r=0,i=s.length;i>r;r++)n=s[r],n.apply(null,t);return!0})},t.prototype.emit=function(){var t,e,o,r,i,s,a;if(e=arguments[0],t=arguments.length>=2?n.call(arguments,1):[],o={type:"emit",channel:this.name,event:e,args:t},this.listeners){for(a=this.listeners,i=0,s=a.length;s>i;i++)r=a[i],r.write(o);return!0}return this.socket?(this.socket.write(o),!0):!1},t.prototype.addListener=function(t,e){var o,n;return this.realEmit("newListener",t,e),(null!=(n=(o=this.events)[t])?n:o[t]=[]).push(e),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(t,e){var o,n=this;return o=function(){return n.removeListener(t,o),e.apply(null,arguments)},this.on(t,o),this},t.prototype.removeSocketListener=function(t){var e;return this.listeners?(this.listeners=function(){var o,n,r,i;for(r=this.listeners,i=[],o=0,n=r.length;n>o;o++)e=r[o],e!==t&&i.push(e);return i}.call(this),this):this},t.prototype.removeListener=function(t,e){var o;return this.events[t]?(this.events[t]=function(){var n,r,i,s;for(i=this.events[t],s=[],n=0,r=i.length;r>n;n++)o=i[n],o!==e&&s.push(o);return s}.call(this),this):this},t.prototype.removeAllListeners=function(t){return delete this.events[t],this},t.prototype.ready=function(t){var e=this;return this.joined?t(this):this.on("join",function(){return t(e)})},t.prototype.use=function(t){return this.stack.push(t),this},t.prototype.runStack=function(t,e,o){var r,i,s=this;return 0===this.stack.length?o(e):"newListener"===t?o(e):(i=-1,r=function(){var a,c;return a=arguments.length>=1?n.call(arguments,0):[],0!==a.length&&(e=a),c=s.stack[++i],null==c?o(e):c.apply(null,[r,t].concat(n.call(e)))},r.apply(null,e),void 0)},t}(),o.exports=t}).call(this)}),t.alias("wearefractal-protosock/dist/main.js","pulsar/deps/protosock/dist/main.js"),t.alias("wearefractal-protosock/dist/Socket.js","pulsar/deps/protosock/dist/Socket.js"),t.alias("wearefractal-protosock/dist/util.js","pulsar/deps/protosock/dist/util.js"),t.alias("wearefractal-protosock/dist/defaultClient.js","pulsar/deps/protosock/dist/defaultClient.js"),t.alias("wearefractal-protosock/dist/Client.js","pulsar/deps/protosock/dist/Client.js"),t.alias("wearefractal-protosock/dist/main.js","pulsar/deps/protosock/index.js"),t.alias("component-emitter/index.js","wearefractal-protosock/deps/emitter/index.js"),t.alias("LearnBoost-engine.io-client/lib/index.js","wearefractal-protosock/deps/engine.io/lib/index.js"),t.alias("LearnBoost-engine.io-client/lib/socket.js","wearefractal-protosock/deps/engine.io/lib/socket.js"),t.alias("LearnBoost-engine.io-client/lib/transport.js","wearefractal-protosock/deps/engine.io/lib/transport.js"),t.alias("LearnBoost-engine.io-client/lib/emitter.js","wearefractal-protosock/deps/engine.io/lib/emitter.js"),t.alias("LearnBoost-engine.io-client/lib/util.js","wearefractal-protosock/deps/engine.io/lib/util.js"),t.alias("LearnBoost-engine.io-client/lib/transports/index.js","wearefractal-protosock/deps/engine.io/lib/transports/index.js"),t.alias("LearnBoost-engine.io-client/lib/transports/polling.js","wearefractal-protosock/deps/engine.io/lib/transports/polling.js"),t.alias("LearnBoost-engine.io-client/lib/transports/polling-xhr.js","wearefractal-protosock/deps/engine.io/lib/transports/polling-xhr.js"),t.alias("LearnBoost-engine.io-client/lib/transports/polling-jsonp.js","wearefractal-protosock/deps/engine.io/lib/transports/polling-jsonp.js"),t.alias("LearnBoost-engine.io-client/lib/transports/websocket.js","wearefractal-protosock/deps/engine.io/lib/transports/websocket.js"),t.alias("LearnBoost-engine.io-client/lib/transports/flashsocket.js","wearefractal-protosock/deps/engine.io/lib/transports/flashsocket.js"),t.alias("LearnBoost-engine.io-client/lib/index.js","wearefractal-protosock/deps/engine.io/index.js"),t.alias("component-emitter/index.js","LearnBoost-engine.io-client/deps/emitter/index.js"),t.alias("LearnBoost-engine.io-protocol/lib/index.js","LearnBoost-engine.io-client/deps/engine.io-parser/lib/index.js"),t.alias("LearnBoost-engine.io-protocol/lib/keys.js","LearnBoost-engine.io-client/deps/engine.io-parser/lib/keys.js"),t.alias("LearnBoost-engine.io-protocol/lib/index.js","LearnBoost-engine.io-client/deps/engine.io-parser/index.js"),t.alias("LearnBoost-engine.io-protocol/lib/index.js","LearnBoost-engine.io-protocol/index.js"),t.alias("visionmedia-debug/index.js","LearnBoost-engine.io-client/deps/debug/index.js"),t.alias("visionmedia-debug/debug.js","LearnBoost-engine.io-client/deps/debug/debug.js"),t.alias("LearnBoost-engine.io-client/lib/index.js","LearnBoost-engine.io-client/index.js"),t.alias("wearefractal-protosock/dist/main.js","wearefractal-protosock/index.js"),t.alias("pulsar/dist/main.js","pulsar/index.js"),"object"==typeof exports?module.exports=t("pulsar"):"function"==typeof define&&define.amd?define(t("pulsar")):window.Pulsar=t("pulsar")})();
+(function(){function t(e,o,n){var r=t.resolve(e);if(null==r){n=n||e,o=o||"root";var i=Error('Failed to require "'+n+'" from "'+o+'"');throw i.path=n,i.parent=o,i.require=!0,i}var s=t.modules[r];return s.exports||(s.exports={},s.client=s.component=!0,s.call(this,s.exports,t.relative(r),s)),s.exports}var e=Object.prototype.hasOwnProperty;t.modules={},t.aliases={},t.resolve=function(o){"/"===o.charAt(0)&&(o=o.slice(1));for(var n=o+"/index.js",r=[o,o+".js",o+".json",o+"/index.js",o+"/index.json"],i=0;r.length>i;i++){var o=r[i];if(e.call(t.modules,o))return o}return e.call(t.aliases,n)?t.aliases[n]:void 0},t.normalize=function(t,e){var o=[];if("."!=e.charAt(0))return e;t=t.split("/"),e=e.split("/");for(var n=0;e.length>n;++n)".."==e[n]?t.pop():"."!=e[n]&&""!=e[n]&&o.push(e[n]);return t.concat(o).join("/")},t.register=function(e,o){t.modules[e]=o},t.alias=function(o,n){if(!e.call(t.modules,o))throw Error('Failed to alias "'+o+'", it does not exist');t.aliases[n]=o},t.relative=function(o){function n(t,e){for(var o=t.length;o--;)if(t[o]===e)return o;return-1}function r(e){var n=r.resolve(e);return t(n,o,e)}var i=t.normalize(o,"..");return r.resolve=function(e){var r=e.charAt(0);if("/"==r)return e.slice(1);if("."==r)return t.normalize(i,e);var s=o.split("/"),a=n(s,"deps")+1;return a||(a=0),e=s.slice(0,a+1).join("/")+"/deps/"+e},r.exists=function(o){return e.call(t.modules,r.resolve(o))},r},t.register("component-emitter/index.js",function(t,e,o){function n(t){return t?r(t):void 0}function r(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}o.exports=n,n.prototype.on=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},n.prototype.once=function(t,e){function o(){n.off(t,o),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},e._off=o,this.on(t,o),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=function(t,e){this._callbacks=this._callbacks||{};var o=this._callbacks[t];if(!o)return this;if(1==arguments.length)return delete this._callbacks[t],this;var n=o.indexOf(e._off||e);return~n&&o.splice(n,1),this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),o=this._callbacks[t];if(o){o=o.slice(0);for(var n=0,r=o.length;r>n;++n)o[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}}),t.register("LearnBoost-engine.io-protocol/lib/index.js",function(t,e){var o=e("./keys"),n=t.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},r=o(n),i={type:"error",data:"parser error"};t.encodePacket=function(t){var e=n[t.type];return void 0!==t.data&&(e+=t.data+""),""+e},t.decodePacket=function(t){var e=t.charAt(0);return Number(e)==e&&r[e]?t.length>1?{type:r[e],data:t.substring(1)}:{type:r[e]}:i},t.encodePayload=function(e){if(!e.length)return"0:";for(var o,n="",r=0,i=e.length;i>r;r++)o=t.encodePacket(e[r]),n+=o.length+":"+o;return n},t.decodePayload=function(e,o){var n;if(""==e)return o(n,!0);for(var r,s,a="",c=0,p=e.length;p>c;c++){var l=e.charAt(c);if(":"!=l)a+=l;else{if(""==a||a!=(r=Number(a)))return o(n,!0);if(s=e.substr(c+1,r),a!=s.length)return o(n,!0);if(s.length)return n=t.decodePacket(s),i.type==n.type&&i.data==n.data?o(n,!0):o(n,c+r==p-1);c+=r,a=""}}return""!=a?o(n,!0):void 0}}),t.register("LearnBoost-engine.io-protocol/lib/keys.js",function(t,e,o){o.exports=Object.keys||function(t){var e=[],o=Object.prototype.hasOwnProperty;for(var n in t)o.call(t,n)&&e.push(n);return e}}),t.register("visionmedia-debug/index.js",function(t,e,o){o.exports="undefined"==typeof window?e("./lib/debug"):e("./debug")}),t.register("visionmedia-debug/debug.js",function(t,e,o){function n(t){return n.enabled(t)?function(e){var o=new Date,r=o-(n[t]||o);n[t]=o,e=t+" "+e+" +"+n.humanize(r),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}o.exports=n,n.names=[],n.skips=[],n.enable=function(t){try{localStorage.debug=t}catch(e){}for(var o=(t||"").split(/[\s,]+/),r=o.length,i=0;r>i;i++)t=o[i].replace("*",".*?"),"-"===t[0]?n.skips.push(RegExp("^"+t.substr(1)+"$")):n.names.push(RegExp("^"+t+"$"))},n.disable=function(){n.enable("")},n.humanize=function(t){var e=1e3,o=6e4,n=60*o;return t>=n?(t/n).toFixed(1)+"h":t>=o?(t/o).toFixed(1)+"m":t>=e?(0|t/e)+"s":t+"ms"},n.enabled=function(t){for(var e=0,o=n.skips.length;o>e;e++)if(n.skips[e].test(t))return!1;for(var e=0,o=n.names.length;o>e;e++)if(n.names[e].test(t))return!0;return!1},window.localStorage&&n.enable(localStorage.debug)}),t.register("LearnBoost-engine.io-client/lib/index.js",function(t,e,o){o.exports=e("./socket"),o.exports.parser=e("engine.io-parser")}),t.register("LearnBoost-engine.io-client/lib/socket.js",function(t,e,o){function n(t,e){if(!(this instanceof n))return new n(t,e);if(e=e||{},"object"==typeof t&&(e=t,t=null),t&&(t=i.parseUri(t),e.host=t.host,e.secure="https"==t.protocol||"wss"==t.protocol,e.port=t.port),this.secure=null!=e.secure?e.secure:p.location&&"https:"==location.protocol,e.host){var o=e.host.split(":");e.hostname=o.shift(),o.length&&(e.port=o.pop())}this.hostname=e.hostname||(p.location?location.hostname:"localhost"),this.port=e.port||(p.location&&location.port?location.port:this.secure?443:80),this.query=e.query||{},this.upgrade=!1!==e.upgrade,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.timestampParam=e.timestampParam||"t",this.timestampRequests=!!e.timestampRequests,this.flashPath=e.flashPath||"",this.transports=e.transports||["polling","websocket","flashsocket"],this.readyState="",this.writeBuffer=[],this.policyPort=e.policyPort||843,this.open(),n.sockets.push(this),n.sockets.evs.emit("add",this)}function r(t){var e={};for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);return e}var i=e("./util"),s=e("./transports"),a=e("./emitter"),c=e("debug")("engine-client:socket");o.exports=n;var p=i.global();a(n.prototype),n.protocol=1,n.sockets=[],n.sockets.evs=new a,n.Socket=n,n.Transport=e("./transport"),n.Emitter=e("./emitter"),n.transports=e("./transports"),n.util=e("./util"),n.parser=e("engine.io-parser"),n.prototype.createTransport=function(t){c('creating transport "%s"',t);var e=r(this.query);e.transport=t,this.id&&(e.sid=this.id);var o=new s[t]({hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:e,forceJSONP:this.forceJSONP,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,flashPath:this.flashPath,policyPort:this.policyPort});return o},n.prototype.open=function(){this.readyState="opening";var t=this.createTransport(this.transports[0]);t.open(),this.setTransport(t)},n.prototype.setTransport=function(t){var e=this;this.transport&&(c("clearing existing transport"),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.flush()}).on("packet",function(t){e.onPacket(t)}).on("error",function(t){e.onError(t)}).on("close",function(){e.onClose("transport close")})},n.prototype.probe=function(t){function e(e){if(!n){n=!0;var i=Error("probe error: "+e);i.transport=o.name,o.close(),o=null,c('probe transport "%s" failed because of error: %s',t,e),r.emit("error",i)}}c('probing transport "%s"',t);var o=this.createTransport(t,{probe:1}),n=!1,r=this;o.once("open",function(){n||(c('probe transport "%s" opened',t),o.send([{type:"ping",data:"probe"}]),o.once("packet",function(i){if(!n)if("pong"==i.type&&"probe"==i.data)c('probe transport "%s" pong',t),r.upgrading=!0,r.emit("upgrading",o),c('pausing current transport "%s"',r.transport.name),r.transport.pause(function(){n||"closed"!=r.readyState&&"closing"!=r.readyState&&(c("changing transport and sending upgrade packet"),o.removeListener("error",e),r.emit("upgrade",o),r.setTransport(o),o.send([{type:"upgrade"}]),o=null,r.upgrading=!1,r.flush())});else{c('probe transport "%s" failed',t);var s=Error("probe error");s.transport=o.name,r.emit("error",s)}}))}),o.once("error",e),o.open(),this.once("close",function(){o&&(c("socket closed prematurely - aborting probe"),n=!0,o.close(),o=null)}),this.once("upgrading",function(t){o&&t.name!=o.name&&(c('"%s" works - aborting "%s"',t.name,o.name),o.close(),o=null)})},n.prototype.onOpen=function(){if(c("socket open"),this.readyState="open",this.emit("open"),this.onopen&&this.onopen.call(this),this.flush(),"open"==this.readyState&&this.upgrade&&this.transport.pause){c("starting upgrade probes");for(var t=0,e=this.upgrades.length;e>t;t++)this.probe(this.upgrades[t])}},n.prototype.onPacket=function(t){if("opening"==this.readyState||"open"==this.readyState)switch(c('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(i.parseJSON(t.data));break;case"pong":this.ping();break;case"error":var e=Error("server error");e.code=t.data,this.emit("error",e);break;case"message":this.emit("data",t.data),this.emit("message",t.data);var o={data:t.data};o.toString=function(){return t.data},this.onmessage&&this.onmessage.call(this,o)}else c('packet received with socket readyState "%s"',this.readyState)},n.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),this.ping(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat)},n.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout(function(){"closed"!=e.readyState&&e.onClose("ping timeout")},t||e.pingInterval+e.pingTimeout)},n.prototype.ping=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout(function(){c("writing ping packet - expecting pong within %sms",t.pingTimeout),t.sendPacket("ping"),t.onHeartbeat(t.pingTimeout)},t.pingInterval)},n.prototype.flush=function(){"closed"!=this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(c("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.writeBuffer=[])},n.prototype.write=n.prototype.send=function(t){return this.sendPacket("message",t),this},n.prototype.sendPacket=function(t,e){var o={type:t,data:e};this.emit("packetCreate",o),this.writeBuffer.push(o),this.flush()},n.prototype.close=function(){return("opening"==this.readyState||"open"==this.readyState)&&(this.onClose("forced close"),c("socket closing - telling transport to close"),this.transport.close(),this.transport.removeAllListeners()),this},n.prototype.onError=function(t){c("socket error %j",t),this.emit("error",t),this.onClose("transport error",t)},n.prototype.onClose=function(t,e){("opening"==this.readyState||"open"==this.readyState)&&(c('socket close with reason: "%s"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.readyState="closed",this.emit("close",t,e),this.onclose&&this.onclose.call(this),this.id=null)},n.prototype.filterUpgrades=function(t){for(var e=[],o=0,n=t.length;n>o;o++)~this.transports.indexOf(t[o])&&e.push(t[o]);return e}}),t.register("LearnBoost-engine.io-client/lib/transport.js",function(t,e,o){function n(t){this.path=t.path,this.hostname=t.hostname,this.port=t.port,this.secure=t.secure,this.query=t.query,this.timestampParam=t.timestampParam,this.timestampRequests=t.timestampRequests,this.readyState=""}var r=(e("./util"),e("engine.io-parser")),i=e("./emitter");o.exports=n,i(n.prototype),n.prototype.onError=function(t,e){var o=Error(t);return o.type="TransportError",o.description=e,this.emit("error",o),this},n.prototype.open=function(){return("closed"==this.readyState||""==this.readyState)&&(this.readyState="opening",this.doOpen()),this},n.prototype.close=function(){return("opening"==this.readyState||"open"==this.readyState)&&(this.doClose(),this.onClose()),this},n.prototype.send=function(t){if("open"!=this.readyState)throw Error("Transport not open");this.write(t)},n.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},n.prototype.onData=function(t){this.onPacket(r.decodePacket(t))},n.prototype.onPacket=function(t){this.emit("packet",t)},n.prototype.onClose=function(){this.readyState="closed",this.emit("close")}}),t.register("LearnBoost-engine.io-client/lib/emitter.js",function(t,e,o){var n;try{n=e("emitter")}catch(r){n=e("emitter-component")}o.exports=n,n.prototype.addEventListener=n.prototype.on,n.prototype.removeEventListener=n.prototype.off,n.prototype.removeListener=n.prototype.off,n.prototype.removeAllListeners=function(){this._callbacks={}}}),t.register("LearnBoost-engine.io-client/lib/util.js",function(t,e){var o=!1;t.global=function(){return"undefined"!=typeof window?window:global},t.inherits=function(t,e){function o(){}o.prototype=e.prototype,t.prototype=new o},t.keys=Object.keys||function(t){var e=[],o=Object.prototype.hasOwnProperty;for(var n in t)o.call(t,n)&&e.push(n);return e},t.on=function(t,e,o,n){t.attachEvent?t.attachEvent("on"+e,o):t.addEventListener&&t.addEventListener(e,o,n)},t.load=function(e){var n=t.global();return n.document&&"complete"===document.readyState||o?e():(t.on(n,"load",e,!1),void 0)},"undefined"!=typeof window&&t.load(function(){o=!0}),t.defer=function(e){return t.ua.webkit&&"undefined"==typeof importScripts?(t.load(function(){setTimeout(e,100)}),void 0):e()};var n=/^[\],:{}\s]*$/,r=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,i=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,s=/(?:^|:|,)(?:\s*\[)+/g,a=/^\s+/,c=/\s+$/;t.parseJSON=function(e){var o=t.global();return"string"==typeof e&&e?(e=e.replace(a,"").replace(c,""),o.JSON&&JSON.parse?JSON.parse(e):n.test(e.replace(r,"@").replace(i,"]").replace(s,""))?Function("return "+e)():void 0):null},t.ua={},t.ua.hasCORS="undefined"!=typeof XMLHttpRequest&&function(){try{var t=new XMLHttpRequest}catch(e){return!1}return void 0!=t.withCredentials}(),t.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent),t.ua.gecko="undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent),t.ua.android="undefined"!=typeof navigator&&/android/i.test(navigator.userAgent),t.ua.ios="undefined"!=typeof navigator&&/^(iPad|iPhone|iPod)$/.test(navigator.platform),t.ua.ios6=t.ua.ios&&/OS 6_/.test(navigator.userAgent),t.request=function(o){if("undefined"==typeof window){var n=e("xmlhttprequest").XMLHttpRequest;return new n}if(o&&"undefined"!=typeof XDomainRequest&&!t.ua.hasCORS)return new XDomainRequest;try{if("undefined"!=typeof XMLHttpRequest&&(!o||t.ua.hasCORS))return new XMLHttpRequest}catch(r){}if(!o)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(r){}};var p=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,l=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.parseUri=function(t){for(var e=p.exec(t||""),o={},n=14;n--;)o[l[n]]=e[n]||"";return o},t.qs=function(t){var e="";for(var o in t)t.hasOwnProperty(o)&&(e.length&&(e+="&"),e+=o+"="+encodeURIComponent(t[o]));return e}}),t.register("LearnBoost-engine.io-client/lib/transports/index.js",function(t,e){function o(t){var e,o=!1,i=!1;if(c.location){var s="https:"==location.protocol,p=location.port;Number(p)!=p&&(p=s?443:80),o=t.host!=location.hostname||p!=t.port,i=t.secure!=s}return e=a.request(o),i&&c.XDomainRequest&&e instanceof c.XDomainRequest?new r(t):e&&!t.forceJSONP?new n(t):new r(t)}var n=e("./polling-xhr"),r=e("./polling-jsonp"),i=e("./websocket"),s=e("./flashsocket"),a=e("../util");t.polling=o,t.websocket=i,t.flashsocket=s;var c=a.global()}),t.register("LearnBoost-engine.io-client/lib/transports/polling.js",function(t,e,o){function n(t){r.call(this,t)}var r=e("../transport"),i=e("../util"),s=e("engine.io-parser"),a=e("debug")("engine.io-client:polling");o.exports=n;var c=i.global();i.inherits(n,r),n.prototype.name="polling",n.prototype.doOpen=function(){this.poll()},n.prototype.pause=function(t){function e(){a("paused"),o.readyState="paused",t()}var o=this;if(this.readyState="pausing",this.polling||!this.writable){var n=0;this.polling&&(a("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){a("pre-pause polling complete"),--n||e()})),this.writable||(a("we are currently writing - waiting to pause"),n++,this.once("drain",function(){a("pre-pause writing complete"),--n||e()}))}else e()},n.prototype.poll=function(){a("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},n.prototype.onData=function(t){a("polling got data %s",t);for(var e=s.decodePayload(t),o=0,n=e.length;n>o;o++){if("opening"==this.readyState&&this.onOpen(),"close"==e[o].type)return this.onClose(),void 0;this.onPacket(e[o])}this.polling=!1,this.emit("pollComplete"),"open"==this.readyState?this.poll():a('ignoring poll - transport state "%s"',this.readyState)},n.prototype.doClose=function(){a("sending close packet"),this.send([{type:"close"}])},n.prototype.write=function(t){var e=this;this.writable=!1,this.doWrite(s.encodePayload(t),function(){e.writable=!0,e.emit("drain")})},n.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",o="";return(c.ActiveXObject||i.ua.android||i.ua.ios6||this.timestampRequests)&&(t[this.timestampParam]=+new Date),t=i.qs(t),this.port&&("https"==e&&443!=this.port||"http"==e&&80!=this.port)&&(o=":"+this.port),t.length&&(t="?"+t),e+"://"+this.hostname+o+this.path+t}}),t.register("LearnBoost-engine.io-client/lib/transports/polling-xhr.js",function(t,e,o){function n(){}function r(t){s.call(this,t),l.location&&(this.xd=t.host!=l.location.hostname||l.location.port!=t.port)}function i(t){this.method=t.method||"GET",this.uri=t.uri,this.xd=!!t.xd,this.async=!1!==t.async,this.data=void 0!=t.data?t.data:null,this.create()}var s=e("./polling"),a=e("../util"),c=e("../emitter"),p=e("debug")("engine.io-client:polling-xhr");o.exports=r,o.exports.Request=i;var l=a.global(),u=l[["Active"].concat("Object").join("X")];a.inherits(r,s),r.prototype.doOpen=function(){var t=this;a.defer(function(){s.prototype.doOpen.call(t)})},r.prototype.request=function(t){return t=t||{},t.uri=this.uri(),t.xd=this.xd,new i(t)},r.prototype.doWrite=function(t,e){var o=this.request({method:"POST",data:t}),n=this;o.on("success",e),o.on("error",function(t){n.onError("xhr post error",t)}),this.sendXhr=o},r.prototype.doPoll=function(){p("xhr poll");var t=this.request(),e=this;t.on("data",function(t){e.onData(t)}),t.on("error",function(t){e.onError("xhr poll error",t)}),this.pollXhr=t},c(i.prototype),i.prototype.create=function(){var t=this.xhr=a.request(this.xd),e=this;if(t.open(this.method,this.uri,this.async),"POST"==this.method)try{t.setRequestHeader?t.setRequestHeader("Content-type","text/plain;charset=UTF-8"):t.contentType="text/plain"}catch(o){}this.xd&&l.XDomainRequest&&t instanceof XDomainRequest?(t.onerror=function(t){e.onError(t)},t.onload=function(){e.onData(t.responseText)},t.onprogress=n):("withCredentials"in t&&(t.withCredentials=!0),t.onreadystatechange=function(){var o;try{if(4!=t.readyState)return;200==t.status||1223==t.status?o=t.responseText:e.onError(t.status)}catch(n){e.onError(n)}void 0!==o&&e.onData(o)}),p("sending xhr with url %s | data %s",this.uri,this.data),t.send(this.data),u&&(this.index=i.requestsCount++,i.requests[this.index]=this)},i.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},i.prototype.onData=function(t){this.emit("data",t),this.onSuccess()},i.prototype.onError=function(t){this.emit("error",t),this.cleanup()},i.prototype.cleanup=function(){this.xhr.onreadystatechange=n,this.xhr.onload=this.xhr.onerror=n;try{this.xhr.abort()}catch(t){}u&&delete i.requests[this.index],this.xhr=null},i.prototype.abort=function(){this.cleanup()},u&&(i.requestsCount=0,i.requests={},l.attachEvent("onunload",function(){for(var t in i.requests)i.requests.hasOwnProperty(t)&&i.requests[t].abort()}))}),t.register("LearnBoost-engine.io-client/lib/transports/polling-jsonp.js",function(t,e,o){function n(t){r.call(this,t),s||(a.___eio||(a.___eio=[]),s=a.___eio),this.index=s.length;var e=this;s.push(function(t){e.onData(t)}),this.query.j=this.index}var r=e("./polling"),i=e("../util");o.exports=n;var s,a=i.global(),c=/\n/g;i.inherits(n,r),n.prototype.doOpen=function(){var t=this;i.defer(function(){r.prototype.doOpen.call(t)})},n.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null),r.prototype.doClose.call(this)},n.prototype.doPoll=function(){var t=this,e=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=function(e){t.onError("jsonp poll error",e)};var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(e,o),this.script=e,i.ua.gecko&&setTimeout(function(){var t=document.createElement("iframe");document.body.appendChild(t),document.body.removeChild(t)},100)},n.prototype.doWrite=function(t,e){function o(){n(),e()}function n(){if(r.iframe)try{r.form.removeChild(r.iframe)}catch(t){r.onError("jsonp polling iframe removal error",t)}try{var e='<iframe src="javascript:0" name="'+r.iframeId+'">';i=document.createElement(e)}catch(t){i=document.createElement("iframe"),i.name=r.iframeId,i.src="javascript:0"}i.id=r.iframeId,r.form.appendChild(i),r.iframe=i}var r=this;if(!this.form){var i,s=document.createElement("form"),a=document.createElement("textarea"),p=this.iframeId="eio_iframe_"+this.index;s.className="socketio",s.style.position="absolute",s.style.top="-1000px",s.style.left="-1000px",s.target=p,s.method="POST",s.setAttribute("accept-charset","utf-8"),a.name="d",s.appendChild(a),document.body.appendChild(s),this.form=s,this.area=a}this.form.action=this.uri(),n(),this.area.value=t.replace(c,"\\n");try{this.form.submit()}catch(l){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"==r.iframe.readyState&&o()}:this.iframe.onload=o}}),t.register("LearnBoost-engine.io-client/lib/transports/websocket.js",function(t,e,o){function n(t){i.call(this,t)}function r(){return"undefined"==typeof window?e("ws"):c.WebSocket||c.MozWebSocket}var i=e("../transport"),s=e("engine.io-parser"),a=e("../util");e("debug")("engine.io-client:websocket"),o.exports=n;var c=a.global();a.inherits(n,i),n.prototype.name="websocket",n.prototype.doOpen=function(){if(this.check()){var t=this;this.socket=new(r())(this.uri()),this.socket.onopen=function(){t.onOpen()},this.socket.onclose=function(){t.onClose()},this.socket.onmessage=function(e){t.onData(e.data)},this.socket.onerror=function(e){t.onError("websocket error",e)}}},n.prototype.write=function(t){for(var e=0,o=t.length;o>e;e++)this.socket.send(s.encodePacket(t[e]))},n.prototype.doClose=function(){this.socket!==void 0&&this.socket.close()},n.prototype.uri=function(){var t=this.query||{},e=this.secure?"wss":"ws",o="";return this.port&&("wss"==e&&443!=this.port||"ws"==e&&80!=this.port)&&(o=":"+this.port),this.timestampRequests&&(t[this.timestampParam]=+new Date),t=a.qs(t),t.length&&(t="?"+t),e+"://"+this.hostname+o+this.path+t},n.prototype.check=function(){var t=r();return!(!t||"__initialize"in t&&this.name===n.prototype.name)}}),t.register("LearnBoost-engine.io-client/lib/transports/flashsocket.js",function(t,e,o){function n(t){s.call(this,t),this.flashPath=t.flashPath,this.policyPort=t.policyPort}function r(t,e){if(u[t])return e();var o=document.createElement("script"),n=!1;c('loading "%s"',t),o.onload=o.onreadystatechange=function(){if(!n&&!u[t]){var r=o.readyState;r&&"loaded"!=r&&"complete"!=r||(c('loaded "%s"',t),o.onload=o.onreadystatechange=null,n=!0,u[t]=!0,e())}},o.async=1,o.src=t;var r=document.getElementsByTagName("head")[0];r.insertBefore(o,r.firstChild)}function i(t,e){function o(n){return t[n]?(r(t[n],function(){o(++n)}),void 0):e()}o(0)}var s=e("./websocket"),a=e("../util"),c=e("debug")("engine.io-client:flashsocket");o.exports=n;var p=a.global(),l=p[["Active"].concat("Object").join("X")];a.inherits(n,s),n.prototype.name="flashsocket",n.prototype.doOpen=function(){function t(t){return function(){var e=Array.prototype.join.call(arguments," ");c("[websocketjs %s] %s",t,e)}}if(this.check()){WEB_SOCKET_LOGGER={log:t("debug"),error:t("error")},WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR=!0,WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0,"undefined"==typeof WEB_SOCKET_SWF_LOCATION&&(WEB_SOCKET_SWF_LOCATION=this.flashPath+"WebSocketMainInsecure.swf");var e=[this.flashPath+"web_socket.js"];"undefined"==typeof swfobject&&e.unshift(this.flashPath+"swfobject.js");var o=this;i(e,function(){o.ready(function(){WebSocket.__addTask(function(){s.prototype.doOpen.call(o)})})})}},n.prototype.doClose=function(){if(this.socket){var t=this;WebSocket.__addTask(function(){s.prototype.doClose.call(t)})}},n.prototype.write=function(){var t=this,e=arguments;WebSocket.__addTask(function(){s.prototype.write.apply(t,e)})},n.prototype.ready=function(t){function e(){n.loaded||(843!=o.policyPort&&WebSocket.loadFlashPolicyFile("xmlsocket://"+o.host+":"+o.policyPort),WebSocket.__initialize(),n.loaded=!0),t.call(o)}if("undefined"!=typeof WebSocket&&"__initialize"in WebSocket&&swfobject&&!(10>swfobject.getFlashPlayerVersion().major)){var o=this;return document.body?e():(a.load(e),void 0)}},n.prototype.check=function(){if("undefined"==typeof window)return!1;if("undefined"!=typeof WebSocket&&!("__initialize"in WebSocket))return!1;if(l){var t=null;try{t=new l("ShockwaveFlash.ShockwaveFlash")}catch(e){}if(t)return!0}else for(var o=0,n=navigator.plugins.length;n>o;o++)for(var r=0,i=navigator.plugins[o].length;i>r;r++)if("Shockwave Flash"==navigator.plugins[o][r].description)return!0;return!1};var u={}}),t.register("wearefractal-protosock/dist/main.js",function(t,e,o){(function(){var t,n,r,i,s,a;a=e("./util"),t=e("./Client"),r=e("./defaultClient"),s={createClientWrapper:function(t){return function(e){return s.createClient(t,e)}},createClient:function(e,o){var n;return n=a.mergePlugins(r,e),new t(n,o)}},("undefined"==typeof window||null===window)&&(n=e("./Server"),i=e("./defaultServer"),e("http").globalAgent.maxSockets=999,s.createServer=function(t,e,o){var r;return r=a.mergePlugins(i,e),new n(t,r,o)},s.createServerWrapper=function(t){return function(e,o){return s.createServer(e,t,o)}}),o.exports=s}).call(this)}),t.register("wearefractal-protosock/dist/Socket.js",function(t,e,o){(function(){var t;t={write:function(t){var e=this;return this.parent.outbound(this,t,function(t){return e.send(t)}),this},disconnect:function(t){return this.close(t),this}},o.exports=t}).call(this)}),t.register("wearefractal-protosock/dist/util.js",function(t,e,o){(function(){var t,n,r={}.hasOwnProperty,i=function(t,e){function o(){this.constructor=t}for(var n in e)r.call(e,n)&&(t[n]=e[n]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t},s=[].slice;t=e("./Socket"),n={extendSocket:function(e){return i(e.prototype,t)},mergePlugins:function(){var t,e,o,r,i,a,c;for(t=arguments.length>=1?s.call(arguments,0):[],o={},a=0,c=t.length;c>a;a++){r=t[a];for(e in r)i=r[e],o[e]="object"==typeof i&&"server"!==e?n.mergePlugins(o[e],i):i}return o}},o.exports=n}).call(this)}),t.register("wearefractal-protosock/dist/defaultClient.js",function(t,e,o){(function(){var t;t={options:{},start:function(){},inbound:function(t,e,o){var n;try{n=JSON.parse(e)}catch(r){this.error(t,r)}o(n)},outbound:function(t,e,o){var n;try{n=JSON.stringify(e)}catch(r){this.error(t,r)}o(n)},validate:function(t,e,o){return o(!0)},invalid:function(){},connect:function(){},message:function(){},error:function(){},close:function(){}},"undefined"!=typeof window&&null!==window&&(t.options={host:window.location.hostname,port:window.location.port.length>0?parseInt(window.location.port):80,secure:"https:"===window.location.protocol},t.options.secure&&(t.options.port=443)),o.exports=t}).call(this)}),t.register("wearefractal-protosock/dist/Client.js",function(t,e,o){(function(){var t,n,r,i,s,a=function(t,e){return function(){return t.apply(e,arguments)}},c={}.hasOwnProperty,p=function(t,e){function o(){this.constructor=t}for(var n in e)c.call(e,n)&&(t[n]=e[n]);return o.prototype=e.prototype,t.prototype=new o,t.__super__=e.prototype,t};s=e("./util"),"undefined"!=typeof window&&null!==window?(r=e("engine.io"),n=e("emitter")):(r=e("engine.io-client"),n=e("events").EventEmitter),s.extendSocket(r.Socket),i=function(t){return t>10?15e3:t>5?5e3:t>3?1e3:1e3},t=function(t){function e(t,e){var o,n,i,s,c,p,l,u,h;null==e&&(e={}),this.reconnect=a(this.reconnect,this),this.handleClose=a(this.handleClose,this),this.handleError=a(this.handleError,this),this.handleMessage=a(this.handleMessage,this),this.handleConnection=a(this.handleConnection,this);for(n in t)i=t[n],this[n]=i;for(n in e)i=e[n],this.options[n]=i;null==(l=(s=this.options).reconnect)&&(s.reconnect=!0),null==(u=(c=this.options).reconnectLimit)&&(c.reconnectLimit=1/0),null==(h=(p=this.options).reconnectTimeout)&&(p.reconnectTimeout=1/0),this.isServer=!1,this.isClient=!0,this.isBrowser="undefined"!=typeof window&&null!==window,o={host:this.options.host,port:this.options.port,secure:this.options.secure,path:"/"+this.options.namespace,resource:this.options.resource,transports:this.options.transports,upgrade:this.options.upgrade,flashPath:this.options.flashPath,policyPort:this.options.policyPort,forceJSONP:this.options.forceJSONP,forceBust:this.options.forceBust,debug:this.options.debug},this.ssocket=new r(o),this.ssocket.parent=this,this.ssocket.once("open",this.handleConnection),this.ssocket.on("error",this.handleError),this.ssocket.on("message",this.handleMessage),this.ssocket.on("close",this.handleClose),this.start()}return p(e,t),e.prototype.disconnect=function(){return this.ssocket.disconnect(),this},e.prototype.destroy=function(){return this.options.reconnect=!1,this.ssocket.disconnect(),this.emit("destroyed"),this},e.prototype.handleConnection=function(){return this.emit("connected"),this.connect(this.ssocket)},e.prototype.handleMessage=function(t){var e=this;return this.emit("inbound",this.ssocket,t),this.inbound(this.ssocket,t,function(t){return e.validate(e.ssocket,t,function(o){return o?(e.emit("message",e.ssocket,t),e.message(e.ssocket,t)):(e.emit("invalid",e.ssocket,t),e.invalid(e.ssocket,t))})})},e.prototype.handleError=function(t){return"string"==typeof t&&(t=Error(t)),this.error(this.ssocket,t)},e.prototype.handleClose=function(t){var e=this;if(!this.ssocket.reconnecting)return this.options.reconnect?this.reconnect(function(o){return null!=o?(e.emit("close",e.ssocket,t),e.close(e.ssocket,t)):void 0}):(this.emit("close",this.ssocket,t),this.close(this.ssocket,t))},e.prototype.reconnect=function(t){var e,o,n,r,s,a,c,p=this;return this.ssocket.reconnecting?t("Already reconnecting"):(this.ssocket.reconnecting=!0,"open"===this.ssocket.readyState&&this.ssocket.disconnect(),a=Date.now(),s=this.options.reconnectLimit,c=this.options.reconnectTimeout,e=0,n=function(){return p.ssocket.reconnecting=!1,p.emit("reconnected"),t()},r=function(e){return p.ssocket.reconnecting=!1,t(e)},this.ssocket.once("open",n),o=function(){return p.ssocket.reconnecting?e>=s?r("Exceeded max attempts"):Date.now()-a>c?r("Timeout on reconnect"):(e++,p.ssocket.open(),setTimeout(o,i(e))):void 0},setTimeout(o,i(e)))},e}(n),o.exports=t}).call(this)}),t.register("pulsar/dist/main.js",function(t,e,o){(function(){var t,n,r;t=e("protosock"),n=e("./Client"),o.exports={createClient:t.createClientWrapper(n)},("undefined"==typeof window||null===window)&&(r=e("./Server"),o.exports.createServer=t.createServerWrapper(r))}).call(this)}),t.register("pulsar/dist/Client.js",function(t,e,o){(function(){var t,n,r=Array.prototype.slice;t=e("./Channel"),n={options:{namespace:"Pulsar",resource:"default"},start:function(){var t=this;
+return this.channels={},this.on("reconnected",function(){var e,o,n,r;n=t.channels,r=[];for(o in n)e=n[o],r.push(e.joinChannel());return r})},channel:function(e){var o,n;return null!=(n=(o=this.channels)[e])?n:o[e]=new t(e,this.ssocket)},validate:function(t,e,o){if("object"!=typeof e)return o(!1);if("string"!=typeof e.type)return o(!1);switch(e.type){case"emit":if("string"!=typeof e.channel)return o(!1);if("string"!=typeof e.event)return o(!1);if(!Array.isArray(e.args))return o(!1);break;case"joined":if("string"!=typeof e.channel)return o(!1);break;default:return o(!1)}return o(!0)},error:function(t,e){return this.emit("error",e,t)},message:function(t,e){var o;switch(o=this.channels[e.channel],e.type){case"emit":return o.realEmit.apply(o,[e.event].concat(r.call(e.args)));case"joined":return o.joined=!0,o.realEmit("join")}}},o.exports=n}).call(this)}),t.register("pulsar/dist/Channel.js",function(t,e,o){(function(){var t,e=function(t,e){return function(){return t.apply(e,arguments)}},n=Array.prototype.slice;t=function(){function t(t,o){this.name=t,this.socket=o,this.runStack=e(this.runStack,this),this.use=e(this.use,this),this.ready=e(this.ready,this),this.removeAllListeners=e(this.removeAllListeners,this),this.removeListener=e(this.removeListener,this),this.once=e(this.once,this),this.addListener=e(this.addListener,this),this.emit=e(this.emit,this),this.realEmit=e(this.realEmit,this),this.events={},this.stack=[],this.joinChannel()}return t.prototype.joinChannel=function(){var t=this;return this.socket?(this.socket.write({type:"join",channel:this.name}),this.socket.once("close",function(){return t.joined=!1})):(this.joined=!0,this.listeners=[])},t.prototype.realEmit=function(){var t,e,o=this;return e=arguments[0],t=arguments.length>=2?n.call(arguments,1):[],this.runStack(e,t,function(t){var n,r,i,s;if(!o.events[e])return!1;for(s=o.events[e],r=0,i=s.length;i>r;r++)n=s[r],n.apply(null,t);return!0})},t.prototype.emit=function(){var t,e,o,r,i,s,a;if(e=arguments[0],t=arguments.length>=2?n.call(arguments,1):[],o={type:"emit",channel:this.name,event:e,args:t},this.listeners){for(a=this.listeners,i=0,s=a.length;s>i;i++)r=a[i],r.write(o);return!0}return this.socket?(this.socket.write(o),!0):!1},t.prototype.addListener=function(t,e){var o,n;return this.realEmit("newListener",t,e),(null!=(n=(o=this.events)[t])?n:o[t]=[]).push(e),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(t,e){var o,n=this;return o=function(){return n.removeListener(t,o),e.apply(null,arguments)},this.on(t,o),this},t.prototype.removeSocketListener=function(t){var e;return this.listeners?(this.listeners=function(){var o,n,r,i;for(r=this.listeners,i=[],o=0,n=r.length;n>o;o++)e=r[o],e!==t&&i.push(e);return i}.call(this),this.emit("unjoin",t),this.realEmit("unjoin",t),this):this},t.prototype.removeListener=function(t,e){var o;return this.events[t]?(this.events[t]=function(){var n,r,i,s;for(i=this.events[t],s=[],n=0,r=i.length;r>n;n++)o=i[n],o!==e&&s.push(o);return s}.call(this),this):this},t.prototype.removeAllListeners=function(t){return delete this.events[t],this},t.prototype.ready=function(t){var e=this;return this.joined?t(this):this.once("join",function(){return t(e)})},t.prototype.use=function(t){return this.stack.push(t),this},t.prototype.runStack=function(t,e,o){var r,i,s=this;return 0===this.stack.length?o(e):"newListener"===t?o(e):(i=-1,r=function(){var a,c;return a=arguments.length>=1?n.call(arguments,0):[],0!==a.length&&(e=a),c=s.stack[++i],null==c?o(e):c.apply(null,[r,t].concat(n.call(e)))},r.apply(null,e),void 0)},t}(),o.exports=t}).call(this)}),t.alias("wearefractal-protosock/dist/main.js","pulsar/deps/protosock/dist/main.js"),t.alias("wearefractal-protosock/dist/Socket.js","pulsar/deps/protosock/dist/Socket.js"),t.alias("wearefractal-protosock/dist/util.js","pulsar/deps/protosock/dist/util.js"),t.alias("wearefractal-protosock/dist/defaultClient.js","pulsar/deps/protosock/dist/defaultClient.js"),t.alias("wearefractal-protosock/dist/Client.js","pulsar/deps/protosock/dist/Client.js"),t.alias("wearefractal-protosock/dist/main.js","pulsar/deps/protosock/index.js"),t.alias("component-emitter/index.js","wearefractal-protosock/deps/emitter/index.js"),t.alias("LearnBoost-engine.io-client/lib/index.js","wearefractal-protosock/deps/engine.io/lib/index.js"),t.alias("LearnBoost-engine.io-client/lib/socket.js","wearefractal-protosock/deps/engine.io/lib/socket.js"),t.alias("LearnBoost-engine.io-client/lib/transport.js","wearefractal-protosock/deps/engine.io/lib/transport.js"),t.alias("LearnBoost-engine.io-client/lib/emitter.js","wearefractal-protosock/deps/engine.io/lib/emitter.js"),t.alias("LearnBoost-engine.io-client/lib/util.js","wearefractal-protosock/deps/engine.io/lib/util.js"),t.alias("LearnBoost-engine.io-client/lib/transports/index.js","wearefractal-protosock/deps/engine.io/lib/transports/index.js"),t.alias("LearnBoost-engine.io-client/lib/transports/polling.js","wearefractal-protosock/deps/engine.io/lib/transports/polling.js"),t.alias("LearnBoost-engine.io-client/lib/transports/polling-xhr.js","wearefractal-protosock/deps/engine.io/lib/transports/polling-xhr.js"),t.alias("LearnBoost-engine.io-client/lib/transports/polling-jsonp.js","wearefractal-protosock/deps/engine.io/lib/transports/polling-jsonp.js"),t.alias("LearnBoost-engine.io-client/lib/transports/websocket.js","wearefractal-protosock/deps/engine.io/lib/transports/websocket.js"),t.alias("LearnBoost-engine.io-client/lib/transports/flashsocket.js","wearefractal-protosock/deps/engine.io/lib/transports/flashsocket.js"),t.alias("LearnBoost-engine.io-client/lib/index.js","wearefractal-protosock/deps/engine.io/index.js"),t.alias("component-emitter/index.js","LearnBoost-engine.io-client/deps/emitter/index.js"),t.alias("LearnBoost-engine.io-protocol/lib/index.js","LearnBoost-engine.io-client/deps/engine.io-parser/lib/index.js"),t.alias("LearnBoost-engine.io-protocol/lib/keys.js","LearnBoost-engine.io-client/deps/engine.io-parser/lib/keys.js"),t.alias("LearnBoost-engine.io-protocol/lib/index.js","LearnBoost-engine.io-client/deps/engine.io-parser/index.js"),t.alias("LearnBoost-engine.io-protocol/lib/index.js","LearnBoost-engine.io-protocol/index.js"),t.alias("visionmedia-debug/index.js","LearnBoost-engine.io-client/deps/debug/index.js"),t.alias("visionmedia-debug/debug.js","LearnBoost-engine.io-client/deps/debug/debug.js"),t.alias("LearnBoost-engine.io-client/lib/index.js","LearnBoost-engine.io-client/index.js"),t.alias("wearefractal-protosock/dist/main.js","wearefractal-protosock/index.js"),t.alias("pulsar/dist/main.js","pulsar/index.js"),"object"==typeof exports?module.exports=t("pulsar"):"function"==typeof define&&define.amd?define(t("pulsar")):window.Pulsar=t("pulsar")})();
View
3 test/mocha.opts
@@ -0,0 +1,3 @@
+--compilers coffee:coffee-script
+--ignore-leaks
+--reporter spec
View
141 test/server.coffee
@@ -5,11 +5,14 @@ Pulsar = require '../'
randomPort = -> Math.floor(Math.random() * 2000) + 8000
-getServer = ->
- Pulsar.createServer http.createServer().listen randomPort()
-
-getClient = (server) ->
- Pulsar.createClient
+getServer = (port) ->
+ port ||= randomPort()
+ server = Pulsar.createServer http.createServer().listen port
+ server.port = port
+ server
+
+getClient = (server) ->
+ Pulsar.createClient
host: server.server.httpServer.address().address
port: server.server.httpServer.address().port
resource: server.options.resource
@@ -205,14 +208,14 @@ describe 'Pulsar', ->
called = false
serv = getServer()
channel = serv.channel 'test'
- channel.use (emit, event, num) ->
- should.exist emit
- should.exist event
- should.exist num
- event.should.equal 'ping'
- num.should.equal 2
- called = true
- emit()
+ channel.use (emit, event, num) ->
+ if event is 'ping'
+ should.exist emit
+ should.exist event
+ should.exist num
+ num.should.equal 2
+ called = true
+ emit()
channel.on 'ping', (num) ->
num.should.equal 2
called.should.be.true
@@ -227,15 +230,14 @@ describe 'Pulsar', ->
called = false
serv = getServer()
channel = serv.channel 'test'
- channel.use (emit, event, num) ->
- console.log event
- should.exist emit
- should.exist event
- should.exist num
- event.should.equal 'ping'
- num.should.equal 2
- called = true
- emit 3
+ channel.use (emit, event, num) ->
+ if event is 'ping'
+ should.exist emit
+ should.exist event
+ should.exist num
+ num.should.equal 2
+ called = true
+ emit 3
channel.on 'ping', (num) ->
num.should.equal 3
called.should.be.true
@@ -247,38 +249,73 @@ describe 'Pulsar', ->
cchan.emit 'ping', 2
describe 'reconnect', ->
- it 'should call on close and buffer messages', (done) ->
- @timeout 5000
+ #it 'should call on close and buffer messages', (done) ->
+ #@timeout 5000
+ #serv = getServer()
+ #channel = serv.channel 'test'
+ #channel2 = serv.channel 'test2'
+ #should.exist channel
+ #should.exist channel2
+
+ #channel.on 'ping', (num) ->
+ #num.should.equal 2
+ #channel.emit 'pong', num
+
+ #channel2.on 'ping', (num) ->
+ #num.should.equal 3
+ #channel2.emit 'pong', num
+
+ #client = getClient serv
+ #cchan = client.channel 'test'
+ #cchan2 = client.channel 'test2'
+ #client.once "connected", ->
+ #cchan.ready ->
+ #cchan2.ready ->
+ #client.disconnect()
+
+ #cchan.emit 'ping', 2
+ #cchan.on 'pong', (num) ->
+ #num.should.equal 2
+
+ #cchan2.emit 'ping', 3
+ #cchan2.on 'pong', (num) ->
+ #num.should.equal 3
+ #serv.destroy()
+ #client.destroy()
+ #done()
+
+ it 'should reconnect channels', (done) ->
serv = getServer()
- channel = serv.channel 'test'
- channel2 = serv.channel 'test2'
- should.exist channel
- should.exist channel2
+ serv2 = null
+ port = serv.port
+ serv.channel 'test'
- channel.on 'ping', (num) ->
+ client = getClient serv
+ cchan = client.channel 'test'
+
+ # tests should pass
+ cchan.on 'pong', (num) ->
num.should.equal 2
- channel.emit 'pong', num
+ client.destroy()
+ serv2.destroy()
+ done()
- channel2.on 'ping', (num) ->
- num.should.equal 3
- channel2.emit 'pong', num
+ # once the client is ready
+ cchan.ready ->
- client = getClient serv
- cchan = client.channel 'test'
- cchan2 = client.channel 'test2'
- client.once "connected", ->
- cchan.ready ->
- cchan2.ready ->
- client.disconnect()
-
- cchan.emit 'ping', 2
- cchan.on 'pong', (num) ->
- num.should.equal 2
-
- cchan2.emit 'ping', 3
- cchan2.on 'pong', (num) ->
- num.should.equal 3
- serv.destroy()
- client.destroy()
- done()
-
+ # disconnect the server
+ serv.disconnect()
+ serv.destroy()
+
+ # create a new server
+ serv2 = getServer port
+ channel = serv2.channel 'test'
+
+ # wire up server response
+ channel.on 'ping', (num) ->
+ num.should.equal 2
+ channel.emit 'pong', num
+
+ # trigger call/response
+ client.on 'reconnected', ->
+ cchan.emit 'ping', 2

0 comments on commit 587c2f1

Please sign in to comment.