Skip to content

Commit

Permalink
Forgot to upload latest changes to the code to prevent making an unne…
Browse files Browse the repository at this point in the history
…cessary websocket.
  • Loading branch information
Henry00IS committed Apr 19, 2018
1 parent 0fb9b2a commit 1f712e6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/WebSocketManager.Client/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ public class Connection

public Connection()
{
_clientWebSocket = new ClientWebSocket();
}

public async Task StartConnectionAsync(string uri)
{
// the connection was lost, probably why we got called again.
if (_clientWebSocket.State != WebSocketState.Open)
// also check if connection was lost, that's probably why we get called multiple times.
if (_clientWebSocket == null || _clientWebSocket.State != WebSocketState.Open)
{
// create a new web-socket so the next connect call works.
_clientWebSocket.Dispose();
_clientWebSocket?.Dispose();
_clientWebSocket = new ClientWebSocket();
}
// don't do anything, we are already connected.
Expand Down

0 comments on commit 1f712e6

Please sign in to comment.