Skip to content

Commit 731fc0c

Browse files
committed
v6.4.0 - Removed sc-emitter and replaced with component-emitter
1 parent 816d8ac commit 731fc0c

File tree

7 files changed

+104
-162
lines changed

7 files changed

+104
-162
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "socketcluster-client",
33
"main": "socketcluster.js",
4-
"version": "6.3.0",
4+
"version": "6.4.0",
55
"homepage": "https://github.com/SocketCluster/socketcluster-client",
66
"description": "SocketCluster JavaScript client",
77
"authors": [

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var SCSocketCreator = require('./lib/scsocketcreator');
44
module.exports.SCSocketCreator = SCSocketCreator;
55
module.exports.SCSocket = SCSocket;
66

7-
module.exports.SCEmitter = require('sc-emitter').SCEmitter;
7+
module.exports.Emitter = require('component-emitter');
88

99
module.exports.connect = function (options) {
1010
return SCSocketCreator.connect(options);
@@ -16,4 +16,4 @@ module.exports.destroy = function (options) {
1616

1717
module.exports.connections = SCSocketCreator.connections;
1818

19-
module.exports.version = '6.3.0';
19+
module.exports.version = '6.4.0';

lib/scsocket.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var SCEmitter = require('sc-emitter').SCEmitter;
1+
var Emitter = require('component-emitter');
22
var SCChannel = require('sc-channel').SCChannel;
33
var Response = require('./response').Response;
44
var AuthEngine = require('./auth').AuthEngine;
@@ -22,7 +22,7 @@ var isBrowser = typeof window != 'undefined';
2222
var SCSocket = function (opts) {
2323
var self = this;
2424

25-
SCEmitter.call(this);
25+
Emitter.call(this);
2626

2727
this.id = null;
2828
this.state = this.CLOSED;
@@ -137,7 +137,7 @@ var SCSocket = function (opts) {
137137
this.connect();
138138
}
139139

140-
this._channelEmitter = new SCEmitter();
140+
this._channelEmitter = new Emitter();
141141

142142
if (isBrowser && this.disconnectOnUnload) {
143143
var unloadHandler = function () {
@@ -152,7 +152,7 @@ var SCSocket = function (opts) {
152152
}
153153
};
154154

155-
SCSocket.prototype = Object.create(SCEmitter.prototype);
155+
SCSocket.prototype = Object.create(Emitter.prototype);
156156

157157
SCSocket.CONNECTING = SCSocket.prototype.CONNECTING = SCTransport.prototype.CONNECTING;
158158
SCSocket.OPEN = SCSocket.prototype.OPEN = SCTransport.prototype.OPEN;
@@ -178,7 +178,7 @@ SCSocket.prototype._privateEventHandlerMap = {
178178
var undecoratedChannelName = this._undecorateChannelName(data.channel);
179179
var channel = this.channels[undecoratedChannelName];
180180
if (channel) {
181-
SCEmitter.prototype.emit.call(this, 'kickOut', data.message, undecoratedChannelName);
181+
Emitter.prototype.emit.call(this, 'kickOut', data.message, undecoratedChannelName);
182182
channel.emit('kickOut', data.message, undecoratedChannelName);
183183
this._triggerChannelUnsubscribe(channel);
184184
}
@@ -214,7 +214,7 @@ SCSocket.prototype._privateEventHandlerMap = {
214214
response.error(err);
215215
self._onSCError(err);
216216
} else {
217-
SCEmitter.prototype.emit.call(self, 'removeAuthToken', oldToken);
217+
Emitter.prototype.emit.call(self, 'removeAuthToken', oldToken);
218218
self._changeToUnauthenticatedState();
219219
response.end();
220220
}
@@ -242,7 +242,7 @@ SCSocket.prototype.deauthenticate = function (callback) {
242242
self._onSCError(err);
243243
} else {
244244
self.emit('#removeAuthToken');
245-
SCEmitter.prototype.emit.call(self, 'removeAuthToken', oldToken);
245+
Emitter.prototype.emit.call(self, 'removeAuthToken', oldToken);
246246
self._changeToUnauthenticatedState();
247247
}
248248
callback && callback(err);
@@ -258,7 +258,7 @@ SCSocket.prototype.connect = SCSocket.prototype.open = function () {
258258
clearTimeout(this._reconnectTimeoutRef);
259259

260260
this.state = this.CONNECTING;
261-
SCEmitter.prototype.emit.call(this, 'connecting');
261+
Emitter.prototype.emit.call(this, 'connecting');
262262

263263
this._changeToPendingAuthState();
264264

@@ -322,7 +322,7 @@ SCSocket.prototype._changeToPendingAuthState = function () {
322322
oldState: oldState,
323323
newState: this.authState
324324
};
325-
SCEmitter.prototype.emit.call(this, 'authStateChange', stateChangeData);
325+
Emitter.prototype.emit.call(this, 'authStateChange', stateChangeData);
326326
}
327327
};
328328

@@ -337,11 +337,11 @@ SCSocket.prototype._changeToUnauthenticatedState = function () {
337337
oldState: oldState,
338338
newState: this.authState
339339
};
340-
SCEmitter.prototype.emit.call(this, 'authStateChange', stateChangeData);
340+
Emitter.prototype.emit.call(this, 'authStateChange', stateChangeData);
341341
if (oldState == this.AUTHENTICATED) {
342-
SCEmitter.prototype.emit.call(this, 'deauthenticate');
342+
Emitter.prototype.emit.call(this, 'deauthenticate');
343343
}
344-
SCEmitter.prototype.emit.call(this, 'authTokenChange', this.signedAuthToken);
344+
Emitter.prototype.emit.call(this, 'authTokenChange', this.signedAuthToken);
345345
}
346346
};
347347

@@ -362,10 +362,10 @@ SCSocket.prototype._changeToAuthenticatedState = function (signedAuthToken) {
362362
this.processPendingSubscriptions();
363363
}
364364

365-
SCEmitter.prototype.emit.call(this, 'authStateChange', stateChangeData);
366-
SCEmitter.prototype.emit.call(this, 'authenticate', signedAuthToken);
365+
Emitter.prototype.emit.call(this, 'authStateChange', stateChangeData);
366+
Emitter.prototype.emit.call(this, 'authenticate', signedAuthToken);
367367
}
368-
SCEmitter.prototype.emit.call(this, 'authTokenChange', signedAuthToken);
368+
Emitter.prototype.emit.call(this, 'authTokenChange', signedAuthToken);
369369
};
370370

371371
SCSocket.prototype.decodeBase64 = function (encodedString) {
@@ -506,7 +506,7 @@ SCSocket.prototype._onSCOpen = function (status) {
506506

507507
// If the user invokes the callback while in autoSubscribeOnConnect mode, it
508508
// won't break anything.
509-
SCEmitter.prototype.emit.call(this, 'connect', status, function () {
509+
Emitter.prototype.emit.call(this, 'connect', status, function () {
510510
self.processPendingSubscriptions();
511511
});
512512

@@ -522,7 +522,7 @@ SCSocket.prototype._onSCError = function (err) {
522522
if (self.listeners('error').length < 1) {
523523
throw err;
524524
} else {
525-
SCEmitter.prototype.emit.call(self, 'error', err);
525+
Emitter.prototype.emit.call(self, 'error', err);
526526
}
527527
}, 0);
528528
};
@@ -605,9 +605,9 @@ SCSocket.prototype._onSCClose = function (code, data, openAbort) {
605605
}
606606

607607
if (openAbort) {
608-
SCEmitter.prototype.emit.call(self, 'connectAbort', code, data);
608+
Emitter.prototype.emit.call(self, 'connectAbort', code, data);
609609
} else {
610-
SCEmitter.prototype.emit.call(self, 'disconnect', code, data);
610+
Emitter.prototype.emit.call(self, 'disconnect', code, data);
611611
}
612612

613613
if (!SCSocket.ignoreStatuses[code]) {
@@ -629,7 +629,7 @@ SCSocket.prototype._onSCEvent = function (event, data, res) {
629629
if (handler) {
630630
handler.call(this, data, res);
631631
} else {
632-
SCEmitter.prototype.emit.call(this, event, data, function () {
632+
Emitter.prototype.emit.call(this, event, data, function () {
633633
res && res.callback.apply(res, arguments);
634634
});
635635
}
@@ -709,7 +709,7 @@ SCSocket.prototype.emit = function (event, data, callback) {
709709
if (this._localEvents[event] == null) {
710710
this._emit(event, data, callback);
711711
} else {
712-
SCEmitter.prototype.emit.call(this, event, data);
712+
Emitter.prototype.emit.call(this, event, data);
713713
}
714714
};
715715

@@ -736,8 +736,8 @@ SCSocket.prototype._triggerChannelSubscribe = function (channel, subscriptionOpt
736736
};
737737
channel.emit('subscribeStateChange', stateChangeData);
738738
channel.emit('subscribe', channelName, subscriptionOptions);
739-
SCEmitter.prototype.emit.call(this, 'subscribeStateChange', stateChangeData);
740-
SCEmitter.prototype.emit.call(this, 'subscribe', channelName, subscriptionOptions);
739+
Emitter.prototype.emit.call(this, 'subscribeStateChange', stateChangeData);
740+
Emitter.prototype.emit.call(this, 'subscribe', channelName, subscriptionOptions);
741741
}
742742
};
743743

@@ -749,7 +749,7 @@ SCSocket.prototype._triggerChannelSubscribeFail = function (err, channel, subscr
749749
channel.state = channel.UNSUBSCRIBED;
750750

751751
channel.emit('subscribeFail', err, channelName, subscriptionOptions);
752-
SCEmitter.prototype.emit.call(this, 'subscribeFail', err, channelName, subscriptionOptions);
752+
Emitter.prototype.emit.call(this, 'subscribeFail', err, channelName, subscriptionOptions);
753753
}
754754
};
755755

@@ -810,7 +810,7 @@ SCSocket.prototype._trySubscribe = function (channel) {
810810
}
811811
}
812812
);
813-
SCEmitter.prototype.emit.call(this, 'subscribeRequest', channel.name, subscriptionOptions);
813+
Emitter.prototype.emit.call(this, 'subscribeRequest', channel.name, subscriptionOptions);
814814
}
815815
};
816816

@@ -851,8 +851,8 @@ SCSocket.prototype._triggerChannelUnsubscribe = function (channel, newState) {
851851
};
852852
channel.emit('subscribeStateChange', stateChangeData);
853853
channel.emit('unsubscribe', channelName);
854-
SCEmitter.prototype.emit.call(this, 'subscribeStateChange', stateChangeData);
855-
SCEmitter.prototype.emit.call(this, 'unsubscribe', channelName);
854+
Emitter.prototype.emit.call(this, 'subscribeStateChange', stateChangeData);
855+
Emitter.prototype.emit.call(this, 'unsubscribe', channelName);
856856
}
857857
};
858858

lib/sctransport.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var SCEmitter = require('sc-emitter').SCEmitter;
1+
var Emitter = require('component-emitter');
22
var Response = require('./response').Response;
33
var querystring = require('querystring');
44
var WebSocket;
@@ -36,7 +36,7 @@ var SCTransport = function (authEngine, codecEngine, options) {
3636
this.open();
3737
};
3838

39-
SCTransport.prototype = Object.create(SCEmitter.prototype);
39+
SCTransport.prototype = Object.create(Emitter.prototype);
4040

4141
SCTransport.CONNECTING = SCTransport.prototype.CONNECTING = 'connecting';
4242
SCTransport.OPEN = SCTransport.prototype.OPEN = 'open';
@@ -135,7 +135,7 @@ SCTransport.prototype._onOpen = function () {
135135
self.socket.close(4003);
136136
} else {
137137
self.state = self.OPEN;
138-
SCEmitter.prototype.emit.call(self, 'open', status);
138+
Emitter.prototype.emit.call(self, 'open', status);
139139
self._resetPingTimeout();
140140
}
141141
});
@@ -199,18 +199,18 @@ SCTransport.prototype._onClose = function (code, data) {
199199

200200
if (this.state == this.OPEN) {
201201
this.state = this.CLOSED;
202-
SCEmitter.prototype.emit.call(this, 'close', code, data);
202+
Emitter.prototype.emit.call(this, 'close', code, data);
203203
this._abortAllPendingEventsDueToBadConnection('disconnect');
204204

205205
} else if (this.state == this.CONNECTING) {
206206
this.state = this.CLOSED;
207-
SCEmitter.prototype.emit.call(this, 'openAbort', code, data);
207+
Emitter.prototype.emit.call(this, 'openAbort', code, data);
208208
this._abortAllPendingEventsDueToBadConnection('connectAbort');
209209
}
210210
};
211211

212212
SCTransport.prototype._onMessage = function (message) {
213-
SCEmitter.prototype.emit.call(this, 'event', 'message', message);
213+
Emitter.prototype.emit.call(this, 'event', 'message', message);
214214

215215
var obj = this.decode(message);
216216

@@ -225,7 +225,7 @@ SCTransport.prototype._onMessage = function (message) {
225225

226226
if (event) {
227227
var response = new Response(this, obj.cid);
228-
SCEmitter.prototype.emit.call(this, 'event', event, obj.data, response);
228+
Emitter.prototype.emit.call(this, 'event', event, obj.data, response);
229229
} else if (obj.rid != null) {
230230

231231
var eventObject = this._callbackMap[obj.rid];
@@ -240,13 +240,13 @@ SCTransport.prototype._onMessage = function (message) {
240240
}
241241
}
242242
} else {
243-
SCEmitter.prototype.emit.call(this, 'event', 'raw', obj);
243+
Emitter.prototype.emit.call(this, 'event', 'raw', obj);
244244
}
245245
}
246246
};
247247

248248
SCTransport.prototype._onError = function (err) {
249-
SCEmitter.prototype.emit.call(this, 'error', err);
249+
Emitter.prototype.emit.call(this, 'error', err);
250250
};
251251

252252
SCTransport.prototype._resetPingTimeout = function () {

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "socketcluster-client",
33
"description": "SocketCluster JavaScript client",
4-
"version": "6.3.0",
4+
"version": "6.4.0",
55
"homepage": "http://socketcluster.io",
66
"contributors": [
77
{
@@ -18,14 +18,14 @@
1818
},
1919
"dependencies": {
2020
"base-64": "0.1.0",
21-
"linked-list": "0.1.0",
2221
"clone": "2.1.1",
22+
"component-emitter": "1.2.1",
23+
"linked-list": "0.1.0",
2324
"querystring": "0.2.0",
24-
"sc-channel": "~1.0.6",
25-
"sc-emitter": "~1.1.0",
25+
"sc-channel": "~1.1.0",
2626
"sc-errors": "~1.3.3",
2727
"sc-formatter": "~3.0.0",
28-
"ws": "3.0.0"
28+
"ws": "3.1.0"
2929
},
3030
"browser": {
3131
"ws": "./lib/ws-browser.js"
@@ -34,6 +34,6 @@
3434
"license": "MIT",
3535
"devDependencies": {
3636
"browserify": "^13.3.0",
37-
"uglify-js": "^2.7.5"
37+
"uglify-js": "^2.8.29"
3838
}
3939
}

0 commit comments

Comments
 (0)