Exemple #1
0
        /// <summary>
        /// Disconnected handler
        /// Switches user to different pool for disconnected users and updates his status to offline
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            var userId = Context.User.Identity.Name;

            AllConnectedParticipants.TryGetValue(userId, out var participant);

            if (participant != null)
            {
                participant.Participant.Status = ChatParticipantStatus.Offline;

                AllConnectedParticipants.TryRemove(userId, out var removedParticipant);
                DisconnectedParticipants.TryAdd(userId, removedParticipant);

                await Clients.All.SendAsync("friendsListChanged");
            }
        }