private void DoReconnectAttempt() { ReconnectAttempt?.Invoke(this, EventArgs.Empty); MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Attempting to reconnect to CnCNet...")); connection.ConnectAsync(); }
private void DoConnectionLost(string reason) { ConnectionLost?.Invoke(this, new ConnectionLostEventArgs(reason)); for (int i = 0; i < channels.Count; i++) { if (!channels[i].Persistent) { channels.RemoveAt(i); i--; } else { channels[i].ClearUsers(); } } MainChannel.AddMessage(new ChatMessage(null, Color.Red, DateTime.Now, "Connection to CnCNet has been lost.")); connected = false; }
private void DoDisconnected() { for (int i = 0; i < channels.Count; i++) { if (!channels[i].Persistent) { channels.RemoveAt(i); i--; } else { channels[i].ClearUsers(); } } MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "You have disconnected from CnCNet.")); connected = false; Disconnected?.Invoke(this, EventArgs.Empty); }
private void DoChannelFull(string channelName) { ChannelFull?.Invoke(this, new ChannelEventArgs(channelName)); int gameIndex = hostedGames.FindIndex(c => c.ChannelName == channelName); string gameName = null; if (gameIndex > -1) { gameName = hostedGames[gameIndex].ChannelName; } string message; message = string.IsNullOrEmpty(gameName) ? "The selected game is full! " + channelName : string.Format("Cannot join game {0}; it is full!", gameName); MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, message)); }
/// <summary> /// Handles situations when the requested name is already in use by another /// IRC user. Adds additional underscores to the name or replaces existing /// characters with underscores. /// </summary> private void DoNameAlreadyInUse() { var charList = ProgramConstants.PLAYERNAME.ToList(); int maxNameLength = ClientConfiguration.Instance.MaxNameLength; if (charList.Count < maxNameLength) { charList.Add('_'); } else { int lastNonUnderscoreIndex = charList.FindLastIndex(c => c != '_'); if (lastNonUnderscoreIndex == -1) { MainChannel.AddMessage(new ChatMessage(Color.White, "Your nickname is invalid or already in use. Please change your nickname in the login screen.")); UserINISettings.Instance.SkipConnectDialog.Value = false; Disconnect(); return; } charList[lastNonUnderscoreIndex] = '_'; } var sb = new StringBuilder(); foreach (char c in charList) { sb.Append(c); } MainChannel.AddMessage(new ChatMessage(Color.White, string.Format("Your name is already in use. Retrying with {0}...", sb.ToString()))); ProgramConstants.PLAYERNAME = sb.ToString(); connection.ChangeNickname(); }
private void DoIncorrectChannelPassword(string channelName) { MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Incorrect password!")); }
private void DoGenericServerMessageReceived(string message) { MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, message)); }
public void OnErrorReceived(string errorMessage) { MainChannel.AddMessage(new ChatMessage(null, Color.Red, DateTime.Now, errorMessage)); }
/// <summary> /// Connects to CnCNet. /// </summary> public void Connect() { disconnect = false; MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Connecting to CnCNet...")); connection.ConnectAsync(); }
private void DoConnected() { connected = true; Connected?.Invoke(this, EventArgs.Empty); MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Connection to CnCNet established.")); }
private void DoConnectAttemptFailed() { ConnectAttemptFailed?.Invoke(this, EventArgs.Empty); MainChannel.AddMessage(new ChatMessage(null, Color.Red, DateTime.Now, "Connecting to CnCNet failed!")); }
private void DoAttemptedServerChanged(string serverName) { MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Attempting connection to " + serverName)); AttemptedServerChanged?.Invoke(this, new AttemptedServerEventArgs(serverName)); }
private void DoGenericServerMessageReceived(string message) { MainChannel.AddMessage(new ChatMessage(message)); }
public void OnErrorReceived(string errorMessage) { MainChannel.AddMessage(new ChatMessage(Color.Red, errorMessage)); }
/// <summary> /// Connects to CnCNet. /// </summary> public void Connect() { disconnect = false; MainChannel.AddMessage(new ChatMessage("Connecting to CnCNet...")); connection.ConnectAsync(); }
private void DoConnected() { connected = true; Connected?.Invoke(this, EventArgs.Empty); MainChannel.AddMessage(new ChatMessage("Connection to CnCNet established.")); }