msgConnectionRequest() 공개 메소드

public msgConnectionRequest ( String IP, String Port, String Name, String CPU ) : String
IP String
Port String
Name String
CPU String
리턴 String
예제 #1
0
 //*************************************
 public bool Join_Swarm(string DstIP, string DstPort,string SrcIP, string SrcPort,string Username)
 {
     Thread t1 = null;
     Thread t2 = null;
     try
     {
         t1 = new Thread(new ThreadStart(mSocket.StartListening));
         t1.Start();
         t1.IsBackground = true;
         string cpu = "1";
         mSocket.SetIP(SrcIP);
         mSocket.SetPort(SrcPort);
         mSocket.SetName(Username);
         mSocket.SetCPU(cpu);
         MessageGenerator msg = new MessageGenerator();
         string mMsg = msg.msgConnectionRequest
             (mSocket.GetIP(), mSocket.GetPort(), mSocket.GetName(), mSocket.GetCPU());
         AsynchronousClient client = new AsynchronousClient();
         client.SetSingleMsg(DstIP, DstPort, mMsg);
         t2 = new Thread(new ThreadStart(client.SendSingleClient));
         t2.Start();
         t2.IsBackground = true;
         return true;
    
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         return false;
     }
     
 }
예제 #2
0
파일: Form1.cs 프로젝트: shranjan/pinac
 private void Connection_Request(object sender, EventArgs e)
 {
     MessageGenerator msg = new MessageGenerator();
     string DstIp = textBox1.Text;
     string DstPort = textBox2.Text;
     string mMsg = msg.msgConnectionRequest
         (mSocket.GetIP(), mSocket.GetPort(), mSocket.GetName(), mSocket.GetCPU());
     AsynchronousClient client = new AsynchronousClient();
     client.SetSingleMsg(DstIp, DstPort,mMsg);
     Thread t = null;
     t = new Thread(new ThreadStart(client.SendSingleClient));
     t.Start();
     t.IsBackground = true;
     this.button1.Enabled = false;
     this.button2.Enabled = false;
     this.button3.Enabled = true;
 }
예제 #3
0
파일: SwarmAPI.cs 프로젝트: shranjan/pinac
        //*************************************
        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;
            }

        }