Exemple #1
0
        public void HandleMessageAsync(PacketInformation pi)
        {
            BackgroundWorker _worker = new BackgroundWorker();

            _worker.DoWork += _worker_DoWork;
            _worker.RunWorkerAsync(pi);


        }
Exemple #2
0
        public ParseStatus Parse(PacketInformation pi)
        {
            if (pi.Message.IndexOf("#HEADSUP") == 0)
            {
                //string[] splitString = pi.Message.Split(' ');
                pi.AllClients.BroadcastAllExcept("#HEADSUP", pi.Sender.AuthenticatedID);

                return ParseStatus.PARSE_COMPLETED_BREAK;
            }

            return ParseStatus.NOT_PARSED;
        }
Exemple #3
0
        public ParseStatus Parse(PacketInformation pi)
        {
            if (pi.Message.IndexOf("#ONLINECHECK") == 0)
            {
                string[] splitString = pi.Message.Split(' ');
                int targetid = int.Parse(splitString[1]);

                pi.Sender.Broadcast(String.Format("#OCRESPONSE {0} {1}", targetid, pi.AllClients.Contains(targetid) ? 1 : 0));
                return ParseStatus.PARSE_COMPLETED_BREAK;
            }

            return ParseStatus.NOT_PARSED;
        }
Exemple #4
0
 public ParseStatus Parse(PacketInformation pi)
 {
     if (pi.Message.IndexOf("#BACK") == 0)
     {
         if (pi.Sender.IsAway != false)
         {
             pi.Sender.IsAway = false;
             pi.AllClients.BroadcastAll(String.Format("#BACK {0} <<<<{1}>>>>", pi.Sender.AuthenticatedID, pi.Sender.AuthenticatedName));
         }
         return ParseStatus.PARSE_COMPLETED_BREAK;
     }
     return ParseStatus.NOT_PARSED;
 }
Exemple #5
0
 public ParseStatus Parse(PacketInformation pi)
 {
     if (pi.Message.IndexOf("#VISIBLE") == 0)
     {
         if (pi.Sender.IsVisible != true)
         {
             pi.Sender.IsVisible = true;
             pi.AllClients.BroadcastAll(String.Format("#ONLINE {0} <<<<{1}>>>>", pi.Sender.AuthenticatedID, pi.Sender.AuthenticatedName));
         }
         return ParseStatus.PARSE_COMPLETED_BREAK;
     }
     return ParseStatus.NOT_PARSED;
 }
Exemple #6
0
        public ParseStatus Parse(PacketInformation pi)
        {
            if (pi.Message.IndexOf("#INVISIBLE") == 0)
            {
                if (pi.Sender.IsVisible != false)
                {
                    pi.Sender.IsVisible = false;
                    pi.AllClients.BroadcastAll(String.Format("#OFFLINE {0}", pi.Sender.AuthenticatedID));
                }
                return ParseStatus.PARSE_COMPLETED_BREAK;
            }

            return ParseStatus.NOT_PARSED;
        }
Exemple #7
0
        public ParseStatus Parse(PacketInformation pi)
        {
            if (pi.Message.IndexOf("#TYPING") == 0)
            {
                string[] splitString = pi.Message.Split(' ');
                int targetid = int.Parse(splitString[1]);
                if (pi.AllClients.Contains(targetid))
                {
                    pi.AllClients[targetid].Broadcast(String.Format("#TYPING {0} <<<<{1}>>>>", pi.Sender.AuthenticatedID, pi.Sender.AuthenticatedName));
                }
                return ParseStatus.PARSE_COMPLETED_BREAK;
            }

            return ParseStatus.NOT_PARSED;
        }
Exemple #8
0
        public ParseStatus Parse(PacketInformation pi)
        {
            if (pi.Message.IndexOf("#AUTH") == 0)
            {
                string[] splitString = pi.Message.Split(' ');
                pi.Log.Add(String.Format("Attempting to authenticate user {0}", splitString[1]));
                pi.Sender.AuthenticatedName = Parsers.ParseName(pi.Message);
                if (!pi.Message.Contains("[INVISIBLE]"))
                    pi.AllClients.BroadcastAll(String.Format("#ONLINE {0} <<<<{1}>>>>", splitString[1], pi.Sender.AuthenticatedName));
                pi.AllClients.Add(pi.Sender, int.Parse(splitString[1]));
                pi.Sender.Broadcast("#AUTHED");
                pi.Log.Add(String.Format("User authenticated. ({0})", pi.Sender.AuthenticatedName));
                return ParseStatus.PARSE_COMPLETED_BREAK;
            }

            return ParseStatus.NOT_PARSED;
        }
Exemple #9
0
        public ParseStatus Parse(PacketInformation pi)
        {
            if (pi.Message.IndexOf("#WHO") == 0)
            {
                var q = (from p in pi.AllClients
                         where (p.AuthenticatedID != pi.Sender.AuthenticatedID) && p.IsVisible
                         select String.Format("{0} <<<<{1}>>>>{2}", p.AuthenticatedID, p.AuthenticatedName,
                         p.IsAway ? "[AWAY]" : String.Empty));

                string response = String.Format("#WHO {0}",
                    string.Join(";;;;", q));

                pi.Sender.Broadcast(response);

                return ParseStatus.PARSE_COMPLETED_BREAK;
            }

            return ParseStatus.NOT_PARSED;
        }
Exemple #10
0
        public ParseStatus HandleMessage(PacketInformation pi)
        {
            bool bParseCompletedContinue = false;

            foreach (IPacket p in this.Packets)
            {
                switch (p.Parse(pi))
                {
                    case ParseStatus.PARSE_COMPLETED_BREAK:
                        return ParseStatus.PARSE_COMPLETED_BREAK;
                    case ParseStatus.PARSE_COMPLETED_CONTINUE:
                        bParseCompletedContinue = true;
                        break;
                }

            }

            if (bParseCompletedContinue)
                return ParseStatus.PARSE_COMPLETED_CONTINUE;
            else
                return ParseStatus.NOT_PARSED;
        }
Exemple #11
0
        public ParseStatus Parse(PacketInformation pi)
        {
            if (pi.Message.IndexOf("#IM") == 0)
            {
                string[] splitString = pi.Message.Split(' ');
                int targetid = int.Parse(splitString[1]);

                pi.Log.Add(String.Format("User {0} is sending a message to {1}", pi.Sender.AuthenticatedID, splitString[1]));
                pi.AllClients.BroadcastTo(String.Format("#IM {0} <<<<{1}>>>> [[[[{2}]]]]", pi.Sender.AuthenticatedID, pi.Sender.AuthenticatedName, Parsers.ParseIM(pi.Message)),
                    targetid);
                /*if (pi.AllClients.Contains(targetid))
                {
                    pi.AllClients[targetid].Broadcast();
                }
                else
                {
                    pi.Sender.Broadcast("#ERROR NOTONLINE");
                }*/
                return ParseStatus.PARSE_COMPLETED_BREAK;
            }

            return ParseStatus.NOT_PARSED;
        }