Beispiel #1
0
 private static void OnPollChat()
 {
     while (Polling)
     {
         try
         {
             if (Lobby.LoggingOut)
             {
                 StopPolling();
                 break;
             }
             if (Lobby.GetLobby().IsConnected())
             {
                 for (string str = DecodeMessage(Lobby.GetLobby().chatroomHelper.GetNextMessage()); (str != null) && (str.Length > 0); str = DecodeMessage(Lobby.GetLobby().chatroomHelper.GetNextMessage()))
                 {
                     EventLog.WriteLine("Message Recieved: {0}", new object[] { str });
                     MessageEventArgs e = new MessageEventArgs(str);
                     if (e.IsCommand)
                     {
                         if (CommandRecieved != null)
                         {
                             CommandRecieved(e);
                         }
                     }
                     else if (MessageRecieved != null)
                     {
                         MessageRecieved(e);
                     }
                 }
             }
             else
             {
                 MessageEventArgs args2 = new MessageEventArgs("//DISCONNECT");
                 if (CommandRecieved != null)
                 {
                     CommandRecieved(args2);
                     CommandRecieved(args2);
                     CommandRecieved(args2);
                 }
                 StopPolling();
             }
             Thread.Sleep(100);
             continue;
         }
         catch (ThreadInterruptedException exception)
         {
             ErrorLog.WriteLine(exception);
             EventLog.WriteLine("Exited out of the chat thread through an interrupt.", new object[0]);
             break;
         }
         catch (Exception exception2)
         {
             ErrorLog.WriteLine(exception2);
             Thread.Sleep(100);
             continue;
         }
     }
 }
Beispiel #2
0
 private void Messaging_CommandRecieved(MessageEventArgs e)
 {
     try
     {
         if (this.OnGetMessage != null)
         {
             int num2;
             string str;
             if (e.Command == "CUST")
             {
                 int num = Convert.ToInt32(e.CommandArgs[0]);
                 num2 = Convert.ToInt32(e.CommandArgs[1]);
                 str = e.CommandArgs[2];
                 string str2 = e.CommandArgs[3];
                 switch (num)
                 {
                     case 0x21:
                     case 0x22:
                         this.OnGetMessage(str, "CUSTOM", new object[] { num.ToString(), num2, str2 });
                         break;
                 }
             }
             else if (e.Command == "NOTIFYJOIN")
             {
                 num2 = Convert.ToInt32(e.CommandArgs[0]);
                 str = e.CommandArgs[1];
                 this.OnGetMessage(str, "NOTIFYJOIN", new object[] { num2 });
             }
             else if (e.Command == "NOTIFYEXIT")
             {
                 num2 = Convert.ToInt32(e.CommandArgs[0]);
                 str = e.CommandArgs[1];
                 this.OnGetMessage(str, "NOTIFYEXIT", new object[] { num2 });
             }
         }
     }
     catch
     {
     }
 }
Beispiel #3
0
 private void DoMessaging_MessageRecieved(MessageEventArgs e)
 {
     string[] strArray = e.Message.Split(">".ToCharArray(), 2);
     string name = strArray[0].Replace("<", "");
     if (name != User.Current.Name)
     {
         string text = strArray[1].Remove(0, 1);
         if (strArray.Length == 2)
         {
             this.AddChat(name, text);
         }
     }
 }
Beispiel #4
0
 private void Messaging_MessageRecieved(MessageEventArgs e)
 {
     VGen1 method = null;
     if ((!base.Disposing && !base.IsDisposed) && base.InvokeRequired)
     {
         if (method == null)
         {
             method = delegate (object objargs) {
                 this.DoMessaging_MessageRecieved(e);
             };
         }
         base.BeginInvoke(method, new object[] { e });
     }
     else
     {
         this.DoMessaging_MessageRecieved(e);
     }
 }
Beispiel #5
0
 private void Messaging_MessageRecieved(MessageEventArgs e)
 {
     EventLog.WriteLine("Test command received: " + e.Message, new object[0]);
 }
Beispiel #6
0
 private void Messaging_CommandRecieved(MessageEventArgs e)
 {
     EventLog.WriteLine("A Message Command was received: " + e.Command, LogCategory.Get("Command"), e.CommandArgs);
     foreach (string str in e.CommandArgs)
     {
         EventLog.WriteLine("Arguement: " + str, LogCategory.Get("Command"), new object[0]);
     }
     string command = e.Command;
     string[] commandArgs = e.CommandArgs;
     string str5 = command.ToLower();
     if (str5 != null)
     {
         if (!(str5 == "event"))
         {
             if (str5 == "notifyexit")
             {
                 this.DisconnectPlayer(Convert.ToInt32(commandArgs[0]));
             }
         }
         else
         {
             string[] strArray2 = commandArgs[0].Split(",=".ToCharArray());
             if (strArray2.Length > 9)
             {
                 int num = Convert.ToInt32(strArray2[1]);
                 string text1 = strArray2[3];
                 string text2 = strArray2[5];
                 string str3 = strArray2[7];
                 string str4 = strArray2[9];
                 int connectionid = Convert.ToInt32(strArray2[11]);
                 if (((num == 3) && ((str4 == "2") || (str4 == "7"))) && (str3 != User.Current.Name))
                 {
                     this.DisconnectPlayer(connectionid);
                 }
             }
         }
     }
     if (this.OnCommandMessage != null)
     {
         this.OnCommandMessage(e);
     }
 }
Beispiel #7
0
 private void Messaging_MessageRecieved(MessageEventArgs e)
 {
     if (!e.IsCommand && (this.OnGetMessage != null))
     {
         string[] strArray = e.Message.Split(" ".ToCharArray(), 2);
         if (strArray.Length == 2)
         {
             this.OnGetMessage(strArray[0].Replace("<", "").Replace(">", ""), "CHAT", new object[] { strArray[1] });
         }
     }
 }
Beispiel #8
0
 private void Messaging_CommandRecieved(MessageEventArgs e)
 {
     if (!base.IsDisposed && !base.Disposing)
     {
         try
         {
             MessageEventArgs args = e;
             GPG.Logging.EventLog.WriteLine("Processing Command: {0}", new object[] { e.Message });
             this.ProcessSystemCommand(args.Command, args.CommandArgs);
         }
         catch (Exception exception)
         {
             ErrorLog.WriteLine(exception);
         }
     }
 }
Beispiel #9
0
 private void DoMessaging_MessageRecieved(MessageEventArgs e)
 {
     try
     {
         string[] strArray = e.Message.Split(">".ToCharArray(), 2);
         string indexValue = strArray[0].Replace("<", "");
         if (indexValue != User.Current.Name)
         {
             string message = strArray[1].Remove(0, 1);
             if (strArray.Length == 2)
             {
                 VGen0 target = null;
                 User user = null;
                 if (!Chatroom.GatheringParticipants.TryFindByIndex("name", indexValue, out user))
                 {
                     if (ConfigSettings.GetBool("ForceLookup", false) && this.TryFindUser(indexValue, true, out user))
                     {
                         if (target == null)
                         {
                             target = delegate {
                                 this.AddChatParticipant(user);
                             };
                         }
                         this.ChatroomQueue.Enqueue(target, new object[0]);
                     }
                     else
                     {
                         if (User.Current.IsAdmin && ConfigSettings.GetBool("ShowAdminSpew", false))
                         {
                             this.SystemMessage("Dropped Message: <" + indexValue + "> " + message, new object[0]);
                         }
                         this.AddChat(User.MakeFakeUser(indexValue), message);
                         ErrorLog.WriteLine("Received Message from unknown user: {0}", new object[] { message });
                         return;
                     }
                 }
                 if ((user != null) && !User.IsUserIgnored(user.ID))
                 {
                     ChatLink[] linkArray = ChatLink.FindLinks(message, ChatLink.Emote);
                     for (int i = 0; i < linkArray.Length; i++)
                     {
                         string charSequence = EmoteLinkMask.GetCharSequence(linkArray[i]);
                         if ((charSequence == null) || (charSequence.Length < 1))
                         {
                             message = message.Replace(ChatLink.Emote.LinkWord, "");
                         }
                         else if (Emote.AllEmotes.ContainsKey(charSequence))
                         {
                             message = message.Replace(linkArray[i].FullUrl, charSequence);
                         }
                     }
                     if (message.Length > 300)
                     {
                         message = message.Substring(0, 300);
                     }
                     bool flag = false;
                     bool flag2 = false;
                     bool flag3 = false;
                     if (message.IndexOf("I am the effect: ") < 0)
                     {
                         if (this.mLastChatTimes.ContainsKey(user))
                         {
                             DateTime time = (DateTime) this.mLastChatTimes[user];
                             TimeSpan span = (TimeSpan) (DateTime.Now - time);
                             flag = span.TotalMilliseconds < (Program.Settings.Chat.SpamInterval * 1000.0);
                             flag2 = span.TotalSeconds < 5.0;
                         }
                         if (flag2 && this.mLastChatContent.ContainsKey(user))
                         {
                             flag3 = e.Message == this.mLastChatContent[user].ToString();
                         }
                     }
                     if ((user.Name == TournamentCommands.sDirectorName) || user.IsAdmin)
                     {
                         flag = false;
                         flag3 = false;
                     }
                     if (!flag && !flag3)
                     {
                         if (message.IndexOf("I am the effect: ") < 0)
                         {
                             this.mLastChatTimes[user] = DateTime.Now;
                             this.mLastChatContent[user] = e.Message;
                         }
                         this.AddChat(user, message);
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }
        private void mTrafficManager_OnCommandMessage(MessageEventArgs e)
        {
            VGen0 gen = null;
            VGen0 gen2 = null;
            EventLog.WriteLine("A TrafficManager Message Command was received: " + e.Command, LogCategory.Get("Command"), e.CommandArgs);
            foreach (string str in e.CommandArgs)
            {
                EventLog.WriteLine("Arguement: " + str, LogCategory.Get("Command"), new object[0]);
            }
            string command = e.Command;
            string[] commandArgs = e.CommandArgs;
            if (this.mSupcomTCPConnection != null)
            {
                switch (command.ToLower())
                {
                    case "attemptjoin":
                        this.mSupcomTCPConnection.SendMessage("Chat", new object[] { commandArgs[0] + Loc.Get("<LOC> is attempting to join the game.") });
                        if (this.mIsHost && ((this.GameState == GPG.Multiplayer.Game.GameState.Launching) || (this.GameState == GPG.Multiplayer.Game.GameState.Playing)))
                        {
                            this.MessageGame("//LAUNCHING " + User.Current.Name.ToString());
                        }
                        return;

                    case "notifyexit":
                        if (((this.mHostName.ToUpper() == commandArgs[1].ToUpper()) && (this.GameState != GPG.Multiplayer.Game.GameState.Launching)) && (this.GameState != GPG.Multiplayer.Game.GameState.Playing))
                        {
                            this.ForceCloseGame(Loc.Get("<LOC>The host has left the game."));
                        }
                        this.mSupcomTCPConnection.SendMessage("Chat", new object[] { commandArgs[1] + Loc.Get("<LOC> has left the game.") });
                        return;

                    case "launching":
                        if (gen == null)
                        {
                            gen = delegate {
                                Thread.Sleep(ConfigSettings.GetInt("Game Abort Timeout", 0x3a98));
                                if ((this.GameState != GPG.Multiplayer.Game.GameState.Launching) && (this.GameState != GPG.Multiplayer.Game.GameState.Playing))
                                {
                                    this.ForceCloseGame(Loc.Get("<LOC>The game has been launched and you can no longer join."));
                                }
                            };
                        }
                        new Thread(new ThreadStart(gen.Invoke)) { IsBackground = true }.Start();
                        return;

                    case "autoabort":
                        if (commandArgs[0].ToUpper() != User.Current.Name)
                        {
                            this.ForceCloseGame(Loc.Get("<LOC>Your opponent has aborted the automatch."));
                        }
                        return;

                    case "playing":
                        if (gen2 == null)
                        {
                            gen2 = delegate {
                                Thread.Sleep(0xbb8);
                                if ((this.GameState != GPG.Multiplayer.Game.GameState.Launching) && (this.GameState != GPG.Multiplayer.Game.GameState.Playing))
                                {
                                    this.ForceCloseGame(Loc.Get("<LOC>The game has been started and you can no longer join."));
                                }
                            };
                        }
                        new Thread(new ThreadStart(gen2.Invoke)) { IsBackground = true }.Start();
                        return;

                    case "teamname":
                    {
                        string str3 = "";
                        foreach (string str4 in commandArgs)
                        {
                            str3 = str3 + str4 + " ";
                        }
                        if (str3.IndexOf(User.Current.ID.ToString() + " ") >= 0)
                        {
                            if ((this.MyTeam == "") || (this.MyTeam.Split(new char[] { ' ' }).Length < str3.Trim().Split(new char[] { ' ' }).Length))
                            {
                                this.MyTeam = str3.Trim();
                                return;
                            }
                        }
                        else if ((this.OtherTeam == "") || (this.OtherTeam.Split(new char[] { ' ' }).Length < str3.Trim().Split(new char[] { ' ' }).Length))
                        {
                            this.OtherTeam = str3.Trim();
                            return;
                        }
                        return;
                    }
                    case "map":
                        try
                        {
                            if (((this.mMapName == "") || (this.mGameInfo.Map == "")) || ((this.mGameInfo.Map == null) || (this.mMapName == null)))
                            {
                                this.mGameInfo.Map = commandArgs[0];
                                this.mMapName = commandArgs[0];
                            }
                        }
                        catch (Exception exception)
                        {
                            ErrorLog.WriteLine(exception);
                        }
                        return;

                    case "playerinfo":
                        try
                        {
                            if (this.mGameInfo != null)
                            {
                                SupcomPlayerInfo info = this.mGameInfo.PlayerByName(commandArgs[1]);
                                int num = Convert.ToInt32(commandArgs[0]);
                                if ((num > 0x3e8) || (info.PlayerID <= 0))
                                {
                                    info.PlayerID = num;
                                }
                                if (commandArgs[2] != "-1")
                                {
                                    info.Army = Convert.ToInt32(commandArgs[2]);
                                }
                            }
                        }
                        catch (Exception exception2)
                        {
                            ErrorLog.WriteLine(exception2);
                        }
                        return;

                    case "discplayer":
                        this.EjectFromGame(Convert.ToInt32(commandArgs[0]));
                        return;

                    default:
                        return;
                }
            }
        }