Exemple #1
0
 public static void Broadcast(ReceiveID type, string text)
 {
     text = checkText + (char)type + text + EOP;
     foreach (Client c in clients)
     {
         c.socket.Send(Encoding.ASCII.GetBytes(text));
     }
 }
Exemple #2
0
        void HandleInformation(string text)
        {
            Console.WriteLine(text);
            if (fraction != null)
            {
                text     = fraction + text;
                fraction = null;
            }

            List <string> package = new List <string>();
            int           lastEOP = 0;

            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] == Server.EOP)
                {
                    if (i - lastEOP == Server.checkText.Length)
                    {
                        continue;
                    }

                    package.Add(text.Substring(lastEOP, i - lastEOP));
                    lastEOP = i + 1;
                }
            }

            if (lastEOP != text.Length)
            {
                fraction = text.Substring(lastEOP, text.Length - lastEOP);
            }

            string s;

            for (int i = 0; i < package.Count; i++)
            {
                s = package[i];
                if (s.IndexOf(Server.checkText) != 0)
                {
                    continue;
                }

                ReceiveID type = (ReceiveID)(s[Server.checkText.Length]);
                if (ReceiveAttribute.all.ContainsKey(type))
                {
                    ReceiveAttribute.all[type].Invoke(null,
                                                      ReceiveAttribute.all[type].IsStatic ?
                                                      new object[2] {
                        this, s.Substring(Server.checkText.Length + 1)
                    } :
                                                      new object[1] {
                        s.Substring(Server.checkText.Length + 1)
                    });
                }
            }
        }
Exemple #3
0
 public void Send(ReceiveID type, string text)
 {
     text = Server.checkText + (char)type + text + Server.EOP;
     socket.Send(Encoding.ASCII.GetBytes(text));
 }
 public ReceiveAttribute(ReceiveID informationType)
 {
     this.informationType = informationType;
 }