Ejemplo n.º 1
0
        private void DoReconnectAttempt()
        {
            ReconnectAttempt?.Invoke(this, EventArgs.Empty);

            MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Attempting to reconnect to CnCNet..."));

            connection.ConnectAsync();
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        /// <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();
        }
Ejemplo n.º 6
0
 private void DoIncorrectChannelPassword(string channelName)
 {
     MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Incorrect password!"));
 }
Ejemplo n.º 7
0
 private void DoGenericServerMessageReceived(string message)
 {
     MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, message));
 }
Ejemplo n.º 8
0
 public void OnErrorReceived(string errorMessage)
 {
     MainChannel.AddMessage(new ChatMessage(null, Color.Red, DateTime.Now, errorMessage));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Connects to CnCNet.
 /// </summary>
 public void Connect()
 {
     disconnect = false;
     MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Connecting to CnCNet..."));
     connection.ConnectAsync();
 }
Ejemplo n.º 10
0
 private void DoConnected()
 {
     connected = true;
     Connected?.Invoke(this, EventArgs.Empty);
     MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Connection to CnCNet established."));
 }
Ejemplo n.º 11
0
        private void DoConnectAttemptFailed()
        {
            ConnectAttemptFailed?.Invoke(this, EventArgs.Empty);

            MainChannel.AddMessage(new ChatMessage(null, Color.Red, DateTime.Now, "Connecting to CnCNet failed!"));
        }
Ejemplo n.º 12
0
 private void DoAttemptedServerChanged(string serverName)
 {
     MainChannel.AddMessage(new ChatMessage(null, Color.White, DateTime.Now, "Attempting connection to " + serverName));
     AttemptedServerChanged?.Invoke(this, new AttemptedServerEventArgs(serverName));
 }
Ejemplo n.º 13
0
 private void DoGenericServerMessageReceived(string message)
 {
     MainChannel.AddMessage(new ChatMessage(message));
 }
Ejemplo n.º 14
0
 public void OnErrorReceived(string errorMessage)
 {
     MainChannel.AddMessage(new ChatMessage(Color.Red, errorMessage));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Connects to CnCNet.
 /// </summary>
 public void Connect()
 {
     disconnect = false;
     MainChannel.AddMessage(new ChatMessage("Connecting to CnCNet..."));
     connection.ConnectAsync();
 }
Ejemplo n.º 16
0
 private void DoConnected()
 {
     connected = true;
     Connected?.Invoke(this, EventArgs.Empty);
     MainChannel.AddMessage(new ChatMessage("Connection to CnCNet established."));
 }