11/**
2- * SocketCluster JavaScript client v11.1 .0
2+ * SocketCluster JavaScript client v11.2 .0
33 */
44( 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 ( ) { function r ( e , n , t ) { function o ( i , f ) { if ( ! n [ i ] ) { if ( ! e [ i ] ) { var c = "function" == typeof require && require ; if ( ! f && c ) return c ( i , ! 0 ) ; if ( u ) return u ( i , ! 0 ) ; var a = new Error ( "Cannot find module '" + i + "'" ) ; throw a . code = "MODULE_NOT_FOUND" , a } var p = n [ i ] = { exports :{ } } ; e [ i ] [ 0 ] . call ( p . exports , function ( r ) { var n = e [ i ] [ 1 ] [ r ] ; return o ( n || r ) } , p , p . exports , r , e , n , t ) } return n [ i ] . exports } for ( var u = "function" == typeof require && require , i = 0 ; i < t . length ; i ++ ) o ( t [ i ] ) ; return o } return r } ) ( ) ( { 1 :[ function ( _dereq_ , module , exports ) {
55var SCSocket = _dereq_ ( './lib/scsocket' ) ;
@@ -22,7 +22,7 @@ module.exports.destroy = function (socket) {
2222
2323module . exports . clients = SCSocketCreator . clients ;
2424
25- module . exports . version = '11.1 .0' ;
25+ module . exports . version = '11.2 .0' ;
2626
2727} , { "./lib/scsocket" :4 , "./lib/scsocketcreator" :5 , "component-emitter" :12 } ] , 2 :[ function ( _dereq_ , module , exports ) {
2828( function ( global ) {
@@ -159,6 +159,7 @@ var clone = _dereq_('clone');
159159var scErrors = _dereq_ ( 'sc-errors' ) ;
160160var InvalidArgumentsError = scErrors . InvalidArgumentsError ;
161161var InvalidMessageError = scErrors . InvalidMessageError ;
162+ var InvalidActionError = scErrors . InvalidActionError ;
162163var SocketProtocolError = scErrors . SocketProtocolError ;
163164var TimeoutError = scErrors . TimeoutError ;
164165var BadConnectionError = scErrors . BadConnectionError ;
@@ -190,6 +191,8 @@ var SCSocket = function (opts) {
190191 // pingTimeout will be ackTimeout at the start, but it will
191192 // be updated with values provided by the 'connect' event
192193 this . pingTimeout = this . ackTimeout ;
194+ this . pingTimeoutDisabled = ! ! opts . pingTimeoutDisabled ;
195+ this . active = true ;
193196
194197 this . _clientMap = opts . clientMap || { } ;
195198
@@ -204,7 +207,6 @@ var SCSocket = function (opts) {
204207
205208 verifyDuration ( 'connectTimeout' ) ;
206209 verifyDuration ( 'ackTimeout' ) ;
207- verifyDuration ( 'pingTimeout' ) ;
208210
209211 this . _localEvents = {
210212 'connect' : 1 ,
@@ -291,10 +293,13 @@ var SCSocket = function (opts) {
291293 self . disconnect ( ) ;
292294 } ;
293295
296+ if ( isBrowser && this . disconnectOnUnload && global . addEventListener ) {
297+ global . addEventListener ( 'beforeunload' , this . _unloadHandler , false ) ;
298+ }
299+ this . _clientMap [ this . clientId ] = this ;
300+
294301 if ( this . options . autoConnect ) {
295302 this . connect ( ) ;
296- } else {
297- this . activate ( ) ;
298303 }
299304} ;
300305
@@ -401,7 +406,11 @@ SCSocket.prototype.deauthenticate = function (callback) {
401406SCSocket . prototype . connect = SCSocket . prototype . open = function ( ) {
402407 var self = this ;
403408
404- this . activate ( ) ;
409+ if ( ! this . active ) {
410+ var error = new InvalidActionError ( 'Cannot connect a destroyed socket' ) ;
411+ this . _onSCError ( error ) ;
412+ return ;
413+ }
405414
406415 if ( this . state == this . CLOSED ) {
407416 this . pendingReconnect = false ;
@@ -463,14 +472,6 @@ SCSocket.prototype.disconnect = function (code, data) {
463472 }
464473} ;
465474
466- SCSocket . prototype . activate = function ( ) {
467- if ( isBrowser && this . disconnectOnUnload && global . addEventListener && ! this . active ) {
468- global . addEventListener ( 'beforeunload' , this . _unloadHandler , false ) ;
469- }
470- this . _clientMap [ this . clientId ] = this ;
471- this . active = true ;
472- } ;
473-
474475SCSocket . prototype . destroy = function ( code , data ) {
475476 if ( isBrowser && global . removeEventListener ) {
476477 global . removeEventListener ( 'beforeunload' , this . _unloadHandler , false ) ;
@@ -580,7 +581,6 @@ SCSocket.prototype.authenticate = function (signedAuthToken, callback) {
580581 var self = this ;
581582
582583 this . emit ( '#authenticate' , signedAuthToken , function ( err , authStatus ) {
583-
584584 if ( authStatus && authStatus . isAuthenticated != null ) {
585585 // If authStatus is correctly formatted (has an isAuthenticated property),
586586 // then we will rehydrate the authError.
@@ -1062,7 +1062,6 @@ SCSocket.prototype._tryUnsubscribe = function (channel) {
10621062} ;
10631063
10641064SCSocket . prototype . unsubscribe = function ( channelName ) {
1065-
10661065 var channel = this . channels [ channelName ] ;
10671066
10681067 if ( channel ) {
@@ -1337,6 +1336,7 @@ var SCTransport = function (authEngine, codecEngine, options) {
13371336 this . options = options ;
13381337 this . connectTimeout = options . connectTimeout ;
13391338 this . pingTimeout = options . ackTimeout ;
1339+ this . pingTimeoutDisabled = ! ! options . pingTimeoutDisabled ;
13401340 this . callIdGenerator = options . callIdGenerator ;
13411341 this . authTokenName = options . authTokenName ;
13421342
@@ -1510,6 +1510,8 @@ SCTransport.prototype._onClose = function (code, data) {
15101510 delete this . socket . onerror ;
15111511
15121512 clearTimeout ( this . _connectTimeoutRef ) ;
1513+ clearTimeout ( this . _pingTimeoutTicker ) ;
1514+ clearTimeout ( this . _batchTimeout ) ;
15131515
15141516 if ( this . state == this . OPEN ) {
15151517 this . state = this . CLOSED ;
@@ -1572,6 +1574,9 @@ SCTransport.prototype._onError = function (err) {
15721574} ;
15731575
15741576SCTransport . prototype . _resetPingTimeout = function ( ) {
1577+ if ( this . pingTimeoutDisabled ) {
1578+ return ;
1579+ }
15751580 var self = this ;
15761581
15771582 var now = ( new Date ( ) ) . getTime ( ) ;
0 commit comments