Skip to content

Commit

Permalink
Fix missing task for send event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellslicer committed Jun 5, 2018
1 parent e83c4bd commit 0295e5d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions WebSocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,20 @@ public WebSocketServer()
{
if (webSocket.IsConnected)
{
if (webSocket.RemoteEndpoint.ToString () == client) {
try
{
await webSocket.WriteStringAsync((string) message, CancellationToken.None);
}
catch (Exception e)
if (webSocket.RemoteEndpoint.ToString () == client)
{
Task.Run(async () =>
{
Log("An error occurred while sending a message to " + webSocket.RemoteEndpoint.ToString() + ": " + e.Message, LogLevels.Debug);
}
}
try
{
await webSocket.WriteStringAsync((string) message, CancellationToken.None);
}
catch (Exception e)
{
Log("An error occurred while sending a message to " + webSocket.RemoteEndpoint.ToString() + ": " + e.Message, LogLevels.Debug);
}
});
}
}
else
{
Expand Down

0 comments on commit 0295e5d

Please sign in to comment.