public async Task DisconnectPlayer() { GlobalData.DisconnectPlayer(Context.ConnectionId); Player player = GetPlayer(Context.ConnectionId); if (player != null) { Room room = GetRoom(player.RoomCode); if (room != null) { await Groups.RemoveFromGroupAsync(Context.ConnectionId, room.RoomCode); await SendPlayerDisconnectionNotification(room, player.Name, player.UID); } } }
public override async Task OnDisconnectedAsync(Exception exception) { Player player = GetPlayer(Context.ConnectionId); if (player != null && player.IsConnected) { Room room = GetRoom(player.RoomCode); if (room != null) { await Groups.RemoveFromGroupAsync(Context.ConnectionId, room.RoomCode); await SendPlayerDisconnectionNotification(room, player.Name, player.UID); } } GlobalData.DisconnectPlayer(Context.ConnectionId); await base.OnDisconnectedAsync(exception); }