Skip to content

Commit 813a736

Browse files
committed
Missing support functions for previous change.
1 parent 57d3515 commit 813a736

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

vis/Code/WebSocketConnection.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)