예제 #1
0
    static void Main(String[] args)
    {
        LBMContext ctx = null; /* Context object: container for UM "instance". */
                LBMEventQueue evq = new LBMEventQueue();

                /* Initialization: create necessary UM objects. */
                try {
                        LBMContextAttributes ctxAttr = new LBMContextAttributes();
                        ctx = new LBMContext(ctxAttr);
                }
                catch(LBMException ex)
                {
                        System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message);
                        System.Environment.Exit(1);
                }

                /* Initialize and create receiver and receiver callback */
                LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

                LBMReceiverAttributes rcv_attr = new LBMReceiverAttributes();
                LBMTopic rtopic = new LBMTopic(ctx, "test.topic", rcv_attr);
                LBMReceiver rcv = new LBMReceiver(ctx, rtopic, myReceiverCallback, evq);

                /* Initialize and create source */
                LBMTopic stopic = new LBMTopic(ctx, "test.topic", new LBMSourceAttributes());
                LBMSource src = new LBMSource(ctx, stopic);

                EQThread evqThread = new EQThread(evq);
                evqThread.start();

                try
                {
                    System.Threading.Thread.Sleep(1000);
                }
                catch (Exception eex)
                {
                    System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + eex.Message);
                    System.Environment.Exit(1);
                }

                src.send(Encoding.ASCII.GetBytes("hello"), 5, LBM.MSG_FLUSH);

                while (cleanup == 0)
                {
                    try
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                    catch (Exception eex)
                    {
                        System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + eex.Message);
                        System.Environment.Exit(1);
                    }
                }

                evq.stop();
                evqThread.join();

                src.close();
                rcv.close();
                ctx.close();
                evq.close();
    }
예제 #2
0
    static void Main(String[] args)
    {
        LBMContext    ctx = null; /* Context object: container for UM "instance". */
        LBMEventQueue evq = new LBMEventQueue();

        /* Initialization: create necessary UM objects. */
        try
        {
            LBMContextAttributes ctxAttr = new LBMContextAttributes();
            ctx = new LBMContext(ctxAttr);
        }
        catch (LBMException ex)
        {
            System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message);
            System.Environment.Exit(1);
        }

        /* Initialize and create receiver and receiver callback */
        LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

        LBMReceiverAttributes rcv_attr = new LBMReceiverAttributes();
        LBMTopic    rtopic             = new LBMTopic(ctx, "test.topic", rcv_attr);
        LBMReceiver rcv = new LBMReceiver(ctx, rtopic, myReceiverCallback, evq);

        /* Initialize and create source */
        LBMTopic  stopic = new LBMTopic(ctx, "test.topic", new LBMSourceAttributes());
        LBMSource src    = new LBMSource(ctx, stopic);

        EQThread evqThread = new EQThread(evq);

        evqThread.start();

        try
        {
            System.Threading.Thread.Sleep(1000);
        }
        catch (Exception eex)
        {
            System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + eex.Message);
            System.Environment.Exit(1);
        }

        src.send(Encoding.ASCII.GetBytes("hello"), 5, LBM.MSG_FLUSH);

        while (cleanup == 0)
        {
            try
            {
                System.Threading.Thread.Sleep(1000);
            }
            catch (Exception eex)
            {
                System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + eex.Message);
                System.Environment.Exit(1);
            }
        }

        evq.stop();
        evqThread.join();

        src.close();
        rcv.close();
        ctx.close();
        evq.close();
    } /* main */