/// <summary> /// Occurs each time the event 'BlockReceived' raised! /// Event does: Blocking the user, or displays the user that has blocked from the server! /// </summary> /// <param name="message">The message information</param> private void OnBlockReceived(ChatMessage message) { int indexOfUser = ConnectedUsers.FindIndex(u => u.UserName == message.SendTo); // Gets the index of the user in the list if (indexOfUser > -1) { ConnectedUsers.RemoveAt(indexOfUser); // Removes the blocked user from the list } }
/// <summary> /// Occurs each time the event 'UserDisconnected' raised! /// Event does: Removes a user who disconnected from the list of connected users! /// </summary> /// <param name="user">The user disconnected</param> private void OnUserDisconnected(UserLogin user) { int indexOfUser = ConnectedUsers.FindIndex(u => u.UserName == user.UserName); // Gets the index of the user in the list if (indexOfUser > -1) { ConnectedUsers.RemoveAt(indexOfUser); // Removes the disconnected user from the list } }