Exemple #1
0
    /**************************************************************/

    static void MainLoop()
    {
        // Open a special thread to read from the console
        Mtalk  mt        = new Mtalk();
        Thread input_thr = new Thread(new ThreadStart(mt.run));

        input_thr.Start();

        while (true)
        {
            // Read all waiting messages from Ensmeble
            while (conn.Poll())
            {
                Message msg = conn.Recv();
                switch (msg.mtype)
                {
                case UpType.VIEW:
                    Console.WriteLine("Install:{ " + memb.current_view.name);
                    Console.WriteLine("  nmembers= " + msg.view.nmembers);
                    Console.Write("  view=[");
                    foreach (string endpt in msg.view.view)
                    {
                        System.Console.Write(":" + endpt);
                    }
                    Console.WriteLine("]");
                    break;

                case UpType.CAST:
                    Console.WriteLine("CAST (" + msg.origin + ") " + System.Text.Encoding.ASCII.GetString(msg.data));
                    break;

                case UpType.SEND:
                    Console.WriteLine("SEND (" + msg.origin + ") " + System.Text.Encoding.ASCII.GetString(msg.data));
                    break;

                case UpType.BLOCK:
                    memb.BlockOk();
                    break;

                case UpType.EXIT:
                    break;
                }
                Console.Out.Flush();
            }
            //Console.WriteLine("sleeping for a little while");
            Thread.Sleep(100);
        }
    }
Exemple #2
0
    /**************************************************************/
    static void MainLoop()
    {
        // Open a special thread to read from the console
        Mtalk mt = new Mtalk();
        Thread input_thr = new Thread(new ThreadStart(mt.run));
        input_thr.Start();

        while(true)
        {
            // Read all waiting messages from Ensmeble
            while (conn.Poll())
            {
                Message msg = conn.Recv();
                switch(msg.mtype)
                {
                    case UpType.VIEW:
                        Console.WriteLine("Install:{ " + memb.current_view.name);
                        Console.WriteLine("  nmembers= " + msg.view.nmembers);
                        Console.Write("  view=[");
                        foreach (string endpt in msg.view.view)
                        {
                            System.Console.Write(":" + endpt);
                        }
                        Console.WriteLine("]");
                        break;
                    case UpType.CAST:
                        Console.WriteLine("CAST (" + msg.origin + ") " + System.Text.Encoding.ASCII.GetString(msg.data));
                        break;
                    case UpType.SEND:
                        Console.WriteLine("SEND (" + msg.origin + ") " + System.Text.Encoding.ASCII.GetString(msg.data));
                        break;
                    case UpType.BLOCK:
                        memb.BlockOk();
                        break;
                    case UpType.EXIT:
                        break;
                }
                Console.Out.Flush();
            }
            //Console.WriteLine("sleeping for a little while");
            Thread.Sleep(100);
        }
    }