static ChunkWriter CreateReliableMulticastWriter(Uri uri) { var writer = new ReliableMulticastWriter(uri); writer.Start(); return(writer); }
public void Run() { var network = new Uri("pgm://224.0.0.7:40001"); ActorRef actor = AnonymousActor.New(inbox => { inbox.Loop(loop => { loop .Receive <A>(message => { Console.WriteLine("Received: " + message.Name); loop.Continue(); }) .Receive <B>(message => { Console.WriteLine("Received: " + message.Address); loop.Continue(); }); }); }); using (var writer = new ReliableMulticastWriter(network)) { writer.Start(); MessageHeaders.MatchHeaderChannel channel; using (var buffer = new BufferedChunkWriter(new PoolFiber(), new TimerScheduler(new PoolFiber()), writer, 64 * 1024)) { buffer.Start(); channel = new MessageHeaders.MatchHeaderChannel( new MatchHeaderChannel(new SerializeChunkChannel(buffer, new FastTextSerializer()))); MessageHeaders.MatchHeaderChannel channel2; using (var buffer2 = new BufferedChunkWriter(new PoolFiber(), new TimerScheduler(new PoolFiber()), writer, 64 * 1024) ) { buffer2.Start(); channel2 = new MessageHeaders.MatchHeaderChannel( new MatchHeaderChannel(new SerializeChunkChannel(buffer2, new FastTextSerializer()))); Console.WriteLine("Writer started"); for (int i = 0; i < 10; i++) { channel.Send(new A { Name = "Joe" }); channel2.Send(new B { Address = "American Way", }); } Console.WriteLine("Sent message"); var reader = new DeserializeChunkChannel(actor, new FastTextSerializer()); using (var listener = new ReliableMulticastListener(network, reader)) { Console.WriteLine("Listener created"); listener.Start(); Console.WriteLine("Listener started"); Thread.Sleep(2000); Console.WriteLine("Leaving Listener"); } Console.WriteLine("Listener stopped"); } } } Console.WriteLine("Sender Stopped"); }
static ChunkWriter CreateReliableMulticastWriter(Uri uri) { var writer = new ReliableMulticastWriter(uri); writer.Start(); return writer; }
public void Run() { var network = new Uri("pgm://224.0.0.7:40001"); ActorRef actor = AnonymousActor.New(inbox => { inbox.Loop(loop => { loop .Receive<A>(message => { Console.WriteLine("Received: " + message.Name); loop.Continue(); }) .Receive<B>(message => { Console.WriteLine("Received: " + message.Address); loop.Continue(); }); }); }); using (var writer = new ReliableMulticastWriter(network)) { writer.Start(); MessageHeaders.MatchHeaderChannel channel; using (var buffer = new BufferedChunkWriter(new PoolFiber(), new TimerScheduler(new PoolFiber()), writer, 64*1024)) { buffer.Start(); channel = new MessageHeaders.MatchHeaderChannel( new MatchHeaderChannel(new SerializeChunkChannel(buffer, new FastTextSerializer()))); MessageHeaders.MatchHeaderChannel channel2; using (var buffer2 = new BufferedChunkWriter(new PoolFiber(), new TimerScheduler(new PoolFiber()), writer, 64*1024) ) { buffer2.Start(); channel2 = new MessageHeaders.MatchHeaderChannel( new MatchHeaderChannel(new SerializeChunkChannel(buffer2, new FastTextSerializer()))); Console.WriteLine("Writer started"); for (int i = 0; i < 10; i++) { channel.Send(new A { Name = "Joe" }); channel2.Send(new B { Address = "American Way", }); } Console.WriteLine("Sent message"); var reader = new DeserializeChunkChannel(actor, new FastTextSerializer()); using (var listener = new ReliableMulticastListener(network, reader)) { Console.WriteLine("Listener created"); listener.Start(); Console.WriteLine("Listener started"); Thread.Sleep(2000); Console.WriteLine("Leaving Listener"); } Console.WriteLine("Listener stopped"); } } } Console.WriteLine("Sender Stopped"); }