/// <summary> /// Executed when a channel user list is received from the IRC server. /// </summary> /// <param name="userNames">The list of user names on the channel in a string array.</param> /// <param name="channelName">The name of the channel for which we received the user list.</param> private void Instance_UserListReceived(string[] userNames, string channelName) { if (this.InvokeRequired) { // Necessary for thread-safety UserListCallback d = new UserListCallback(Instance_UserListReceived); this.BeginInvoke(d, userNames, channelName); return; } bool updatePlayerList = false; bool channelFound = false; int channelIndex = GameCollection.Instance.GetGameIndexFromChatChannelName(channelName); if (channelIndex > -1) { foreach (string userName in userNames) { if (CnCNetData.players.FindIndex(c => c == userName) == -1) CnCNetData.players.Add(userName); if (userName.StartsWith("@")) { IrcUser iu = new IrcUser(userName.Substring(1), true); UserLists[channelIndex].Add(iu); } else { IrcUser iu = new IrcUser(userName, false); UserLists[channelIndex].Add(iu); } } if (cmbCurrentChannel.SelectedIndex == channelIndex) updatePlayerList = true; channelFound = true; } if (!channelFound) { DoUserListReceived(userNames, channelName); } else if (updatePlayerList) { UpdatePlayerList(); } }
/// <summary> /// Called whenever a channel user list is received from the IRC server. /// </summary> /// <param name="userNames">The list of user names on a channel.</param> /// <param name="channelName">The name of the channel for which the user list was received.</param> private void NCnCNetLobby_UserListReceived(string[] userNames, string channelName) { if (this.InvokeRequired) { // Necessary for thread-safety UserListCallback d = new UserListCallback(NCnCNetLobby_UserListReceived); this.BeginInvoke(d, userNames, channelName); return; } if (channelName != ChannelName) return; if (isHost) return; bool adminFound = false; foreach (string userName in userNames) { if (userName == "@" + ProgramConstants.CNCNET_PLAYERNAME) { MessageBox.Show("The host has left the game.", "Game cancelled"); btnLeaveGame.PerformClick(); return; } else if (userName.Substring(0, 1) == "@") adminFound = true; } if (!adminFound) { MessageBox.Show("The host has left the game.", "Game cancelled"); btnLeaveGame.PerformClick(); return; } }