checkpoint

This commit is contained in:
2021-11-10 18:46:29 -06:00
parent 2a3b7b32b4
commit 20f44c8b90
26 changed files with 519 additions and 407 deletions

View File

@@ -3,6 +3,7 @@ using Gameboard.ShogiUI.Sockets.Models;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net.WebSockets;
@@ -106,9 +107,32 @@ namespace Gameboard.ShogiUI.Sockets.Managers
foreach (var kvp in connections)
{
var socket = kvp.Value;
tasks.Add(socket.SendTextAsync(message));
try
{
tasks.Add(socket.SendTextAsync(message));
}
catch (WebSocketException webSocketException)
{
logger.LogInformation("Tried sending a message to socket connection for user [{user}], but found the connection has closed.", kvp.Key);
UnsubscribeFromBroadcastAndGames(kvp.Key);
}
catch (Exception exception)
{
logger.LogInformation("Tried sending a message to socket connection for user [{user}], but found the connection has closed.", kvp.Key);
UnsubscribeFromBroadcastAndGames(kvp.Key);
}
}
return Task.WhenAll(tasks);
try
{
var task = Task.WhenAll(tasks);
return task;
}
catch (Exception e)
{
Console.WriteLine("Yo");
}
return Task.FromResult(0);
}
//public Task BroadcastToGame(string gameName, IResponse forPlayer1, IResponse forPlayer2)