Skip to content

Commit

Permalink
Missing support functions for previous change.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilliamson committed Apr 24, 2022
1 parent 57d3515 commit 813a736
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions vis/Code/WebSocketConnection.js
Expand Up @@ -15,10 +15,14 @@ WebSocketConnection = (function()
}


WebSocketConnection.prototype.Connecting = function()
{
return this.Socket != null && this.Socket.readyState == WebSocket.CONNECTING;
}

WebSocketConnection.prototype.Connected = function()
{
// Will return true if the socket is also in the process of connecting
return this.Socket != null;
return this.Socket != null && this.Socket.readyState == WebSocket.OPEN;
}


Expand All @@ -45,9 +49,8 @@ WebSocketConnection = (function()

WebSocketConnection.prototype.Connect = function(address)
{
// Disconnect if already connected
if (this.Connected())
this.Disconnect();
// Abandon previous connection attempt
this.Disconnect();

Log(this, "Connecting to " + address);

Expand All @@ -63,8 +66,11 @@ WebSocketConnection = (function()
WebSocketConnection.prototype.Disconnect = function()
{
Log(this, "Disconnecting");
if (this.Connected())
if (this.Socket != null)
{
this.Socket.close();
this.Socket = null;
}
}


Expand Down

0 comments on commit 813a736

Please sign in to comment.