Exemplo n.º 1
0
        public void connectWithManager(NetworkNode nd, Form1 form1)
        {
            Agent agent = new Agent(nd, form1);

            form1.Data(DateTime.Now.ToLongTimeString() + ":" + DateTime.Now.Millisecond.ToString() + "Connect With Manager");
            agent.Start();
        }
Exemplo n.º 2
0
        public Agent(NetworkNode _nd, Form1 _form)
        {
            nd = _nd;
            LabelAction la = new LabelAction(_nd);

            form = _form;
        }
Exemplo n.º 3
0
        public NetworkNode ReadRouterConfig()
        {
            XmlTextReader reader = null;

            try
            {
                var content = Environment.GetCommandLineArgs()[1];
                reader = new XmlTextReader(content);
            }
            catch
            {
                reader = new XmlTextReader("..\\..\\..\\..\\Config\\config3.xml");
            }
            //var content = Environment.GetCommandLineArgs()[1];
            //XmlTextReader reader = new XmlTextReader("..\\..\\..\\..\\Config\\config1.xml");
            //XmlTextReader reader = new XmlTextReader(content);

            //var content = Environment.GetCommandLineArgs()[1];
            // XmlTextReader reader = new XmlTextReader("..\\..\\..\\..\\Config\\config1.xml");
            //XmlTextReader reader = new XmlTextReader(content);

            while (reader.Read())
            {
                if (reader.Name.Equals("managerIP"))
                {
                    reader.Read();
                    table2[0] = reader.Value;
                    reader.Read();
                }
                else if (reader.Name.Equals("managerPort"))
                {
                    reader.Read();
                    Int32.TryParse(reader.Value, out table[0]);
                    reader.Read();
                }
                else if (reader.Name.Equals("nodeName"))
                {
                    reader.Read();
                    table2[1] = reader.Value;
                    reader.Read();
                }
                else if (reader.Name.Equals("cloudIP"))
                {
                    reader.Read();
                    table2[2] = reader.Value;
                    reader.Read();
                }
                else if (reader.Name.Equals("cloudPort"))
                {
                    reader.Read();
                    Int32.TryParse(reader.Value, out table[1]);
                    reader.Read();
                }
            }
            //reader.Close();
            NetworkNode nd = new NetworkNode(table2[1], table2[0], table[0], table2[2], table[1]);

            return(nd);
        }
Exemplo n.º 4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 form1 = new Form1();

            NetworkNode nd = new NetworkNode();
            ReadConfig  rd = new ReadConfig();

            nd         = rd.ReadRouterConfig();
            form1.Text = nd.name;
            Task responseTask  = Task.Run(() => nd.connect(nd, form1, "127.0.0.1"));
            Task responseTask2 = Task.Run(() => nd.connectWithManager(nd, form1));

            //responseTask.ContinueWith(t => Console.WriteLine("In ContinueWith"));
            //responseTask.Wait();

            // Task.Run(() => nd.sendPacket(nd, form1, "127.0.0.1"));

            Application.Run(form1);
        }
Exemplo n.º 5
0
 public ConnectWithCloud(NetworkNode _nd, Form1 form1, string ip1)
 {
     form = form1;
     nd   = _nd;
     ip   = ip1;
 }
Exemplo n.º 6
0
 public LabelAction(NetworkNode network)
 {
     nd = network;
 }
Exemplo n.º 7
0
 public void sendPacket(NetworkNode nd, Form1 form1, string ip)
 {
     // ConnectWithCloud connect = new ConnectWithCloud(nd, form1, ip);
     //  connect.send();
 }
Exemplo n.º 8
0
        public void connect(NetworkNode nd, Form1 form1, string ip)
        {
            ConnectWithCloud connect = new ConnectWithCloud(nd, form1, ip);

            connect.connectWithCloud();
        }