File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,11 @@ var ShareDBError = require('../error');
5
5
var types = require ( '../types' ) ;
6
6
var util = require ( '../util' ) ;
7
7
8
+ function connectionState ( socket ) {
9
+ if ( socket . readyState === 0 || socket . readyState === 1 ) return 'connecting' ;
10
+ return 'disconnected' ;
11
+ }
12
+
8
13
/**
9
14
* Handles communication with the sharejs server and provides queries and
10
15
* documents.
@@ -48,7 +53,7 @@ function Connection(socket) {
48
53
49
54
this . debug = false ;
50
55
51
- this . state = 'disconnected'
56
+ this . state = connectionState ( socket ) ;
52
57
53
58
this . bindToSocket ( socket ) ;
54
59
}
@@ -92,7 +97,8 @@ Connection.prototype.bindToSocket = function(socket) {
92
97
// - 'disconnected' Connection is closed, but it will reconnect automatically
93
98
// - 'closed' The connection was closed by the client, and will not reconnect
94
99
// - 'stopped' The connection was closed by the server, and will not reconnect
95
- this . _setState ( ( socket . readyState === 0 || socket . readyState === 1 ) ? 'connecting' : 'disconnected' ) ;
100
+ var newState = connectionState ( socket ) ;
101
+ this . _setState ( newState ) ;
96
102
97
103
// This is a helper variable the document uses to see whether we're
98
104
// currently in a 'live' state. It is true if and only if we're connected
You can’t perform that action at this time.
0 commit comments