SendSingleClient() public method

public SendSingleClient ( ) : void
return void
Example #1
0
        //*************************************
        public bool Join_Swarm(string DstIP, string DstPort, string SrcIP, string SrcPort, string Username)
        {
            Thread t1 = null;
            Thread t2 = null;
            try
            {
                string cpu = "1";
                mSocket.SetIP(SrcIP);
                mSocket.SetPort(SrcPort);
                mSocket.SetName(Username);
                mSocket.SetCPU(cpu);

                listenerThread = new Thread(new ThreadStart(mSocket.StartListening));
                listenerThread.IsBackground = true;
                listenerThread.Start();

                t1 = new Thread(new ThreadStart(mSocket.StarHeartBeat));
                t1.IsBackground = true;
                t1.Start();

                MessageGenerator msg = new MessageGenerator();
                string mMsg = msg.msgConnectionRequest
                    (mSocket.GetIP(), mSocket.GetPort(), mSocket.GetName(), mSocket.GetCPU());
                AsynchronousClient client = new AsynchronousClient();
                client.ErrorExcep += new AsynchronousClient.EventHandlerExcep(Error_Changed);
                client.SetSingleMsg(DstIP, DstPort, mMsg);
                // t2 = new Thread(new ThreadStart(client.SendSingleClient));
                client.SendSingleClient();
                // t2.Start();
                // t2.IsBackground = true;
                Thread.Sleep(2000);
                if (mSocket.GetIPtoPeer().Count > 0)
                    return true;
                else
                    return false;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failed to join swarm.");
                return false;
            }

        }