Пример #1
0
        public void Init()
        {
            LBMContext    lbmContext    = new LBMContext();
            LBMEventQueue lbmEventQueue = new LBMEventQueue();

            var topicString = "bxu";

            LBMreqCB lbMreqCallBack = new LBMreqCB(0);

            for (int i = 0; i < 10; i++)
            {
                var        requestMsg = Encoding.UTF8.GetBytes(string.Format("request {0}", i));
                LBMRequest lbmRequest = new LBMRequest(requestMsg, requestMsg.Length);
                lbmRequest.addResponseCallback(lbMreqCallBack.onResponse);

                Console.Out.WriteLine("Sending RequestImmediateAndEvent {0}", i);

                lbmContext.send(topicString, lbmRequest, lbmEventQueue, 0);

                var qTimer = new EQTimer(lbmContext, 5000, lbmEventQueue);
                lbmEventQueue.run(LBM.EVENT_QUEUE_BLOCK);

                Console.Out.WriteLine("Done waiting for responses, {0} response{1} ({2} total bytes) received. Deleting request.\n",
                                      lbMreqCallBack.response_count, (lbMreqCallBack.response_count == 1 ? "" : "s"), lbMreqCallBack.response_byte_count);

                lbMreqCallBack.response_count      = 0;
                lbMreqCallBack.response_byte_count = 0;

                lbmRequest.close();
            }

            Console.ReadLine();
        }
Пример #2
0
 public void run()
 {
     while (cleanup == 0)
     {
         _evq.run(1000);
     }
 }
Пример #3
0
        public void Init()
        {
            using (LBMContext lbmContext = new LBMContext())
            {
                LBMTopic lbmTopic = new LBMTopic(lbmContext, "Greeting");

                var cbArg         = new object();
                var lbmEventQueue = new LBMEventQueue();
                using (LBMReceiver lbmReceiver = new LBMReceiver(lbmContext, lbmTopic, LBMReceiverCallback, cbArg, lbmEventQueue))
                {
                    lbmEventQueue.run(-1);
                    Console.WriteLine("Press any key to exit...");
                    Console.ReadLine();
                }
            }
        }
Пример #4
0
    static void Main(String[] args)
    {
        LBMContext          ctx = null;                               /* Context object: container for UM "instance". */
        LBMReceiver         rcv = null;                               /* Source object: for sending messages. */
        LBMEventQueue       evq = null;                               /* Event Queue object: process receiver events on app thread */
        LBMReceiverCallback cb  = new LBMReceiverCallback(onReceive); /* Wrapping the onReceive functor in a callback */

        ctx = new LBMContext();
        evq = new LBMEventQueue();
        {
            LBMTopic topic = null;
            topic = ctx.lookupTopic("test.topic");

            /* The event queue object is passed into the receiver constructor */
            /* This causes events to be queued in an unbounded Q.  In order   */
            /* to process these messages the evq.Run() method must be called  */
            rcv = new LBMReceiver(ctx, topic, onReceive, null, evq);
        }


        /* run the event queue for 60 seconds           */
        /* all the receiver events will be processed    */
        /* in this thread. This includes message        */
        /* processing.							        */
        evq.run(60000);

        try {
            /* Shutdown order is important.  Event Queues should */
            /* be .close()d after the context and receiver.      */
            rcv.close();
            ctx.close();
            evq.close();
        }
        catch (LBMException ex)
        {
            System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
            System.Environment.Exit(1);
        }
    }
Пример #5
0
    static void Main(String[] args)
    {
        LBMContext ctx = null; /* Context object: container for UM "instance". */
        LBMReceiver rcv = null; /* Source object: for sending messages. */
        LBMEventQueue evq = null; /* Event Queue object: process receiver events on app thread */
        LBMReceiverCallback cb = new LBMReceiverCallback(onReceive);    /* Wrapping the onReceive functor in a callback */

        ctx = new LBMContext();
        evq = new LBMEventQueue();
        {
            LBMTopic topic = null;
            topic = ctx.lookupTopic("test.topic");

            /* The event queue object is passed into the receiver constructor */
            /* This causes events to be queued in an unbounded Q.  In order   */
            /* to process these messages the evq.Run() method must be called  */
            rcv = new LBMReceiver(ctx, topic, onReceive, null, evq);
        }

        /* run the event queue for 60 seconds         	*/
        /* all the receiver events will be processed  	*/
        /* in this thread. This includes message 		*/
        /* processing.							  		*/
        evq.run(60000);

        try {
            /* Shutdown order is important.  Event Queues should */
            /* be .close()d after the context and receiver.      */
            rcv.close();
            ctx.close();
            evq.close();
        }
        catch(LBMException ex)
        {
            System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
            System.Environment.Exit(1);
        }
    }
Пример #6
0
        public void Init()
        {
            LBMContext    lbmContext    = new LBMContext();
            LBMEventQueue lbmEventQueue = new LBMEventQueue();

            var topicString = "bxu";
            var lbmTopic    = lbmContext.allocTopic(topicString, null);
            var lbmSource   = lbmContext.createSource(lbmTopic, onSourceEvent, null, null);

            for (int i = 0; i < 10; i++)
            {
                var        requestMsg = Encoding.UTF8.GetBytes(string.Format("request {0}", i));
                LBMRequest lbmRequest = new LBMRequest(requestMsg, requestMsg.Length);
                lbmRequest.addResponseCallback(onResponse);

                Console.Out.WriteLine("Sending RequestNOImmediateAndEvent {0}", i);

                lbmSource.send(lbmRequest, lbmEventQueue, 0);

                var qTimer = new EQTimer(lbmContext, 5000, lbmEventQueue);
                lbmEventQueue.run(LBM.EVENT_QUEUE_BLOCK);
            }
        }