Ejemplo n.º 1
0
        private void Button1Click(object sender, EventArgs e)
        {
            int port = (int)numericUpDown1.Value++;

            if (_nodes.ContainsKey(port))
            {
                textBox1.AppendText("Node Already Exists at port " + port + "\n");
                return;
            }

            string[] nodelines    = textBox2.Lines;
            string[] newNodeLines = new string[nodelines.Length + 1];
            Array.Copy(nodelines, newNodeLines, nodelines.Length);
            newNodeLines[nodelines.Length] = port.ToString();
            textBox2.Lines = newNodeLines;
            var mrNetworkNode = new MrNetworkNode(port);

            mrNetworkNode.AddListener((arg) =>
            {
                textBox1.BeginInvoke((MethodInvoker)(() => { textBox1.AppendText(arg + "\n"); }));
            });
            _nodes.Add(port, mrNetworkNode);

            textBox1.AppendText("Node Started at port " + port + "\n");
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("NodeApp Lives!");

            var mrnn = new MrNetworkNode(1901);

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            mrnn.Stop();
        }