Exemplo n.º 1
0
        static void WaitTcpConnect(object ob)
        {
            EventsClass.PackageSave   Event = (EventsClass.PackageSave)((object[])ob)[0];
            EventsClass.AddToAddrList AddEv = (EventsClass.AddToAddrList)((object[])ob)[1];
            TcpListener Listener            = new TcpListener(7778);

            Listener.Start();
            TcpClient Client = Listener.AcceptTcpClient();

            byte[] buf = new byte[4];

            Client.GetStream().Read(buf, 0, 4);

            int Length = BitConverter.ToInt32(buf, 0);

            for (int i = 0; i < Length; i++)
            {
                buf = new byte[37];
                Client.GetStream().Read(buf, 0, 37);
                AddEv?.Invoke(IPAddress.Parse(buf[0] + "." + buf[1] + "." + buf[2] + "." + buf[3]), 7777);

                PersonNetDataPackage PersonData = new PersonNetDataPackage();
                ReadFromBuffer(PersonData, buf, null);

                Event?.BeginInvoke(PersonData, null, null);
            }
            FileTools.Log("Person list got");
        }
Exemplo n.º 2
0
        public PackageReciever(EventsClass.PackageSave Ev, List <Person> ls, EventsClass.AddToAddrList AddEv) : base()
        {
            ConnectWaiter    = new Thread(new ParameterizedThreadStart(PackageWait));
            TcpConnectWaiter = new Thread(new ParameterizedThreadStart(WaitTcpConnect));
            object[] ob = new object[2];
            ob[0] = Ev;
            ob[1] = ls;

            ConnectWaiter.Start(ob);
            FileTools.Log("Connect waiter start");

            ob    = new object[2];
            ob[0] = Ev;
            ob[1] = AddEv;
            TcpConnectWaiter.Start(ob);
            FileTools.Log("TCP Connect waiter start");
        }