Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jondubois committed Nov 29, 2015
1 parent 1a650bf commit ccba9f7
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 46 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socketcluster-client",
"main": "socketcluster.js",
"version": "3.0.0",
"version": "3.1.0",
"homepage": "https://github.com/SocketCluster/socketcluster-client",
"description": "SocketCluster JavaScript client",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module.exports.destroy = function (options) {
return SCSocketCreator.destroy(options);
};

module.exports.version = '2.4.1';
module.exports.version = '3.1.0';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socketcluster-client",
"description": "SocketCluster JavaScript client",
"version": "3.0.0",
"version": "3.1.0",
"homepage": "http://socketcluster.io",
"contributors": [
{
Expand Down
137 changes: 96 additions & 41 deletions socketcluster.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.socketCluster = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var SCSocket = require('./lib/scsocket');
var SCSocketCreator = require('./lib/scsocketcreator');

module.exports.SCSocketCreator = SCSocketCreator;
module.exports.SCSocket = SCSocket;

module.exports.SCEmitter = require('sc-emitter').SCEmitter;

module.exports.connect = function (options) {
return new SCSocket(options);
return SCSocketCreator.connect(options);
};

module.exports.destroy = function (options) {
return SCSocketCreator.destroy(options);
};

module.exports.version = '3.0.0';
module.exports.version = '3.1.0';

},{"./lib/scsocket":5,"sc-emitter":11}],2:[function(require,module,exports){
},{"./lib/scsocket":5,"./lib/scsocketcreator":6,"sc-emitter":12}],2:[function(require,module,exports){
(function (global){
var AuthEngine = function () {
this._internalStorage = {};
Expand Down Expand Up @@ -141,31 +148,11 @@ if (!Object.create) {
var isBrowser = typeof window != 'undefined';


var SCSocket = function (options) {
var SCSocket = function (opts) {
var self = this;

SCEmitter.call(this);

var opts = {
port: null,
autoReconnect: true,
autoProcessSubscriptions: true,
ackTimeout: 10000,
hostname: global.location && location.hostname,
path: '/socketcluster/',
secure: global.location && location.protocol == 'https:',
timestampRequests: false,
timestampParam: 't',
authEngine: null,
authTokenName: 'socketCluster.authToken',
binaryType: 'arraybuffer'
};
for (var i in options) {
if (options.hasOwnProperty(i)) {
opts[i] = options[i];
}
}

this.id = null;
this.state = this.CLOSED;
this.pendingConnectCallback = false;
Expand Down Expand Up @@ -222,6 +209,8 @@ var SCSocket = function (options) {
this.options.autoReconnectOptions = {};
}

// Add properties to the this.options.autoReconnectOptions object.
// We assign the reference to a reconnectOptions variable to avoid repetition.
var reconnectOptions = this.options.autoReconnectOptions;
if (reconnectOptions.initialDelay == null) {
reconnectOptions.initialDelay = 10000;
Expand Down Expand Up @@ -254,9 +243,6 @@ var SCSocket = function (options) {
this.options.query = querystring.parse(this.options.query);
}

this.options.port = opts.port || (global.location && location.port ?
location.port : (this.options.secure ? 443 : 80));

this.connect();

this._channelEmitter = new SCEmitter();
Expand Down Expand Up @@ -902,7 +888,76 @@ SCSocket.prototype.watchers = function (channelName) {
module.exports = SCSocket;

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./auth":2,"./objectcreate":3,"./response":4,"./sctransport":6,"linked-list":8,"querystring":18,"sc-channel":9,"sc-emitter":11}],6:[function(require,module,exports){
},{"./auth":2,"./objectcreate":3,"./response":4,"./sctransport":7,"linked-list":9,"querystring":19,"sc-channel":10,"sc-emitter":12}],6:[function(require,module,exports){
(function (global){
var SCSocket = require('./scsocket');

var _connections = {};

function getMultiplexId(isSecure, hostname, port, path) {
var protocolPrefix = isSecure ? 'https://' : 'http://';
return protocolPrefix + hostname + ':' + port + path;
}

function connect(options) {
var self = this;
options = options || {};
var isSecure = global.location && location.protocol == 'https:';
var opts = {
port: options.port || global.location && location.port ? location.port : isSecure ? 443 : 80,
autoReconnect: true,
autoProcessSubscriptions: true,
ackTimeout: 10000,
hostname: global.location && location.hostname,
path: '/socketcluster/',
secure: isSecure,
timestampRequests: false,
timestampParam: 't',
authEngine: null,
authTokenName: 'socketCluster.authToken',
binaryType: 'arraybuffer',
multiplex: true
};
for (var i in options) {
if (options.hasOwnProperty(i)) {
opts[i] = options[i];
}
}
var multiplexId = getMultiplexId(isSecure, opts.hostname, opts.port, opts.path);
if (opts.multiplex === false) {
return new SCSocket(opts);
}
if (!_connections[multiplexId]) {
_connections[multiplexId] = new SCSocket(opts);
}
return _connections[multiplexId];
}

function destroy(options) {
var self = this;
options = options || {};
var isSecure = global.location && location.protocol == 'https:';
var opts = {
port: options.port || global.location && location.port ? location.port : isSecure ? 443 : 80,
hostname: global.location && location.hostname,
path: '/socketcluster/'
};
for (var i in options) {
if (options.hasOwnProperty(i)) {
opts[i] = options[i];
}
}
var multiplexId = getMultiplexId(isSecure, opts.hostname, opts.port, opts.path);
delete _connections[multiplexId];
}

module.exports = {
connect: connect,
destroy: destroy
};

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./scsocket":5}],7:[function(require,module,exports){
var WebSocket = require('sc-ws');
var SCEmitter = require('sc-emitter').SCEmitter;
var formatter = require('sc-formatter');
Expand Down Expand Up @@ -1221,7 +1276,7 @@ SCTransport.prototype.sendObject = function (object) {

module.exports.SCTransport = SCTransport;

},{"./response":4,"querystring":18,"sc-emitter":11,"sc-formatter":14,"sc-ws":15}],7:[function(require,module,exports){
},{"./response":4,"querystring":19,"sc-emitter":12,"sc-formatter":15,"sc-ws":16}],8:[function(require,module,exports){
'use strict';

/**
Expand Down Expand Up @@ -1609,12 +1664,12 @@ ListItemPrototype.append = function (item) {

module.exports = List;

},{}],8:[function(require,module,exports){
},{}],9:[function(require,module,exports){
'use strict';

module.exports = require('./_source/linked-list.js');

},{"./_source/linked-list.js":7}],9:[function(require,module,exports){
},{"./_source/linked-list.js":8}],10:[function(require,module,exports){
var SCEmitter = require('sc-emitter').SCEmitter;

if (!Object.create) {
Expand Down Expand Up @@ -1675,9 +1730,9 @@ SCChannel.prototype.destroy = function () {

module.exports.SCChannel = SCChannel;

},{"./objectcreate":10,"sc-emitter":11}],10:[function(require,module,exports){
},{"./objectcreate":11,"sc-emitter":12}],11:[function(require,module,exports){
arguments[4][3][0].apply(exports,arguments)
},{"dup":3}],11:[function(require,module,exports){
},{"dup":3}],12:[function(require,module,exports){
var Emitter = require('component-emitter');

if (!Object.create) {
Expand Down Expand Up @@ -1710,7 +1765,7 @@ SCEmitter.prototype.emit = function (event) {

module.exports.SCEmitter = SCEmitter;

},{"./objectcreate":13,"component-emitter":12}],12:[function(require,module,exports){
},{"./objectcreate":14,"component-emitter":13}],13:[function(require,module,exports){

/**
* Expose `Emitter`.
Expand Down Expand Up @@ -1873,9 +1928,9 @@ Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};

},{}],13:[function(require,module,exports){
},{}],14:[function(require,module,exports){
arguments[4][3][0].apply(exports,arguments)
},{"dup":3}],14:[function(require,module,exports){
},{"dup":3}],15:[function(require,module,exports){
(function (global){
var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

Expand Down Expand Up @@ -1964,7 +2019,7 @@ module.exports.stringify = function (object) {
};

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],15:[function(require,module,exports){
},{}],16:[function(require,module,exports){

/**
* Module dependencies.
Expand Down Expand Up @@ -2009,7 +2064,7 @@ function ws(uri, protocols, opts) {

if (WebSocket) ws.prototype = WebSocket.prototype;

},{}],16:[function(require,module,exports){
},{}],17:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
Expand Down Expand Up @@ -2095,7 +2150,7 @@ var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};

},{}],17:[function(require,module,exports){
},{}],18:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
Expand Down Expand Up @@ -2182,11 +2237,11 @@ var objectKeys = Object.keys || function (obj) {
return res;
};

},{}],18:[function(require,module,exports){
},{}],19:[function(require,module,exports){
'use strict';

exports.decode = exports.parse = require('./decode');
exports.encode = exports.stringify = require('./encode');

},{"./decode":16,"./encode":17}]},{},[1])(1)
},{"./decode":17,"./encode":18}]},{},[1])(1)
});
4 changes: 2 additions & 2 deletions socketcluster.min.js

Large diffs are not rendered by default.

0 comments on commit ccba9f7

Please sign in to comment.