New connection control.
This commit is contained in:
@@ -66,7 +66,14 @@ public class GamesController : Controller
|
||||
subscription = channel.Subscribe(async t => { await _pusher.SendMessage(t.Content); });
|
||||
while (_pusher.Connected)
|
||||
{
|
||||
await Task.Delay(10 * 1000);
|
||||
try
|
||||
{
|
||||
await Task.Delay(int.MaxValue, HttpContext.RequestAborted);
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
@@ -114,6 +121,7 @@ public class GamesController : Controller
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
game.Move(move);
|
||||
var fen = game.ToFen();
|
||||
var channel = _database.GetOrAddChannel(id);
|
||||
|
||||
@@ -18,7 +18,14 @@ public class WebSocketPusher : IScopedDependency
|
||||
|
||||
public async Task SendMessage(string message)
|
||||
{
|
||||
await (_ws?.SendMessage(message) ?? throw new InvalidOperationException("WebSocket is not connected!"));
|
||||
try
|
||||
{
|
||||
await (_ws?.SendMessage(message) ?? throw new InvalidOperationException("WebSocket is not connected!"));
|
||||
}
|
||||
catch (WebSocketException)
|
||||
{
|
||||
_dropped = true;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PendingClose()
|
||||
|
||||
Reference in New Issue
Block a user