public lbmlatpongreceiver(LBMContext lbmctx, LBMTopic lbmtopic, lbmlatpong mylatpong, LBMSource src) { latpong = mylatpong; source = src; receiver = new LBMReceiver(lbmctx, lbmtopic, new LBMReceiverCallback(onReceive), null, null); }
public static int Main(string[] args) { lbmlatpong latpong = null; LBMContext ctx = null; LBMContextAttributes ctx_attr = null; LBMTopic pong_src_topic = null; LBMSourceAttributes pong_src_topic_attr = null; LBMSource pong_src = null; LBMTopic ping_rcv_topic = null; LBMReceiverAttributes ping_rcv_topic_attr = null; lbmlatpongreceiver ping_rcv = null; latpong = new lbmlatpong(args); if (latpong.cpu >= 0) { Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(latpong.cpu); } /* Create the context. */ ctx_attr = new LBMContextAttributes(); ctx_attr.setValue("resolver_cache", "0"); ctx_attr.setValue("operational_mode", "sequential"); ctx_attr.setValue("request_tcp_port_high", "50000"); ctx_attr.setValue("transport_lbtipc_receiver_thread_behavior", "busy_wait"); ctx = new LBMContext(ctx_attr); ctx_attr.dispose(); /* Create the pong source. */ pong_src_topic_attr = new LBMSourceAttributes(); pong_src_topic_attr.setValue("resolver_advertisement_sustain_interval", "0"); pong_src_topic_attr.setValue("transport", "lbtsmx"); pong_src_topic = new LBMTopic(ctx, "lbmlat-pong", pong_src_topic_attr); pong_src_topic_attr.dispose(); pong_src = new LBMSource(ctx, pong_src_topic); latpong.pong_src = pong_src; /* Create the ping receiver. */ ping_rcv_topic_attr = new LBMReceiverAttributes(); ping_rcv_topic_attr.enableSingleReceiverCallback(true); ping_rcv_topic_attr.setSourceNotificationCallbacks( new LBMSourceCreationCallback(latpong.onNewSource), new LBMSourceDeletionCallback(latpong.onSourceDelete), null); ping_rcv_topic = new LBMTopic(ctx, "lbmlat-ping", ping_rcv_topic_attr); ping_rcv_topic_attr.dispose(); ping_rcv = new lbmlatpongreceiver(ctx, ping_rcv_topic, latpong, pong_src); /* Wait a bit for things to get set up. */ System.Threading.Thread.Sleep(1000); /* Run the context until we've discovered the pinger's source. */ while (!latpong.found_pinger) { ctx.processEvents(1000); } /* Wait a bit for things to get set up. */ System.Threading.Thread.Sleep(1000); /* Send in a dummy pong message to kick things off. */ IntPtr writeBuff; if (pong_src.buffAcquire(out writeBuff, (uint)16, 0) == 0) { Marshal.WriteInt64(writeBuff, 0, 1234567890); pong_src.buffsComplete(); } /* Wait forever. */ while (true) { System.Threading.Thread.Sleep(1000000); // ctx.processEvents(1000000); } }