Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        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);
        }