Exemplo n.º 1
0
        private void SendToAll(string mes)
        {
            MyClient m = new MyClient();

            Socket[] asoc = m.GetListAll();
            byte[]   bmsg = new byte[1024];
            bmsg = Encoding.Unicode.GetBytes(mes);
            foreach (Socket s in asoc)
            {
                s.Send(bmsg);
            }
        }
Exemplo n.º 2
0
 private void SendToSpecificClient(string mes, string Cname)
 {
     //Console.WriteLine(Cname + " " + mes);
     if (mes.Length >= 0)
     {
         string     SelectItem = Cname;
         string     Ip         = SelectItem.Substring(0, SelectItem.IndexOf(":"));
         string     Port       = SelectItem.Substring(SelectItem.IndexOf(":") + 1, SelectItem.Length - SelectItem.IndexOf(":") - 1);
         IPEndPoint IpEpoint   = new IPEndPoint(IPAddress.Parse(Ip), int.Parse(Port));
         MyClient   m          = new MyClient();
         m.SendMsg(IpEpoint, mes);
     }
 }
Exemplo n.º 3
0
        private void GetAllClientList()
        {
            MyClient m = new MyClient();

            Socket[] msoc = m.GetListAll();
            ListAllClinet.Clear();
            allclinet.Clear();
            int index = 0;

            foreach (Socket s in msoc)
            {
                IPEndPoint Ip = s.RemoteEndPoint as IPEndPoint;
                ListAllClinet.Add(Ip.Address + ":" + Ip.Port, index);
                allclinet.Add(Ip.Address + ":" + Ip.Port);
                index++;
            }
            int    a     = rnd.Next(2500, 5000);
            int    b     = rnd.Next(2300, 4700);
            int    c     = rnd.Next(20, 30);
            string rands = "ran:" + a + ":" + b + ":" + c + ":" + (index);

            SendToSpecificClient(rands, allclinet[index - 1]);
            //Console.WriteLine(ListAllClinet[index-1]);
        }