File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -15,10 +15,14 @@ WebSocketConnection = (function()
1515 }
1616
1717
18+ WebSocketConnection . prototype . Connecting = function ( )
19+ {
20+ return this . Socket != null && this . Socket . readyState == WebSocket . CONNECTING ;
21+ }
22+
1823 WebSocketConnection . prototype . Connected = function ( )
1924 {
20- // Will return true if the socket is also in the process of connecting
21- return this . Socket != null ;
25+ return this . Socket != null && this . Socket . readyState == WebSocket . OPEN ;
2226 }
2327
2428
@@ -45,9 +49,8 @@ WebSocketConnection = (function()
4549
4650 WebSocketConnection . prototype . Connect = function ( address )
4751 {
48- // Disconnect if already connected
49- if ( this . Connected ( ) )
50- this . Disconnect ( ) ;
52+ // Abandon previous connection attempt
53+ this . Disconnect ( ) ;
5154
5255 Log ( this , "Connecting to " + address ) ;
5356
@@ -63,8 +66,11 @@ WebSocketConnection = (function()
6366 WebSocketConnection . prototype . Disconnect = function ( )
6467 {
6568 Log ( this , "Disconnecting" ) ;
66- if ( this . Connected ( ) )
69+ if ( this . Socket != null )
70+ {
6771 this . Socket . close ( ) ;
72+ this . Socket = null ;
73+ }
6874 }
6975
7076
You can’t perform that action at this time.
0 commit comments