public static void Main() { const string channel = "aeron:ipc"; const int streamId = 42; var buffer = new UnsafeBuffer(new byte[256]); var handler = HandlerHelper.ToFragmentHandler(PrintMessage); try { using (var aeron = Aeron.Connect()) using (var publisher = aeron.AddPublication(channel, streamId)) using (var subscriber = aeron.AddSubscription(channel, streamId)) { var message = buffer.PutStringWithoutLengthUtf8(0, "Hello World!"); publisher.Offer(buffer, 0, message); Console.WriteLine("Message sent..."); while (subscriber.Poll(handler, 1) == 0) { Thread.Sleep(10); } } } catch (Exception ex) { Console.WriteLine(ex); } finally { Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } }
static void Main() { var ctx = new AeronCluster.Context() .EgressMessageListener(new MessageListener()); using (var c = AeronCluster.Connect(ctx)) { var idleStrategy = ctx.IdleStrategy(); var msgBuffer = new UnsafeBuffer(new byte[100]); var len = msgBuffer.PutStringWithoutLengthUtf8(0, "Hello World!"); while (c.Offer(42, msgBuffer, 0, len) < 0) { idleStrategy.Idle(); } while (c.PollEgress() <= 0) { idleStrategy.Idle(); } } }