public static void test1() { string input = string.Empty; string expectedAddress = "XXXXxxxx"; string message = string.Empty; using (var context = ZmqContext.Create()) { using (var pub = GetConnectedPublishSocket(context)) { //using (var sub = GetConnectedSubscribeSocket(context)) //{ ISerializer serializer = new TestHelpers.Serializer(Encoding.Unicode); Customer cust = new Customer(); cust.Firstname = "Johnx"; cust.Lastname = "Wilson"; using (var actor = new Actor(context)) { actor.RegisterActor <Customer>("Basic", expectedAddress, "OutRoute", serializer, (Message, InRoute, OutRoute, Socket, Actor) => { var customer = (Customer)Message; //Assert.AreEqual(cust.Firstname, customer.Firstname); Helper.Writeline(customer.Firstname, @"c:\dev\xx.log"); }); actor.StartAllActors(); Thread.Sleep(0); } for (int i = 0; i < 10; i++) { cust.Firstname = i.ToString(); SendOneMessageOfType <Customer>(expectedAddress, cust, serializer, pub); Thread.Sleep(0); } SendOneSimpleMessage(expectedAddress, "stop", pub); Thread.Sleep(0); } //pipe.Exit(); //Thread.Sleep(0); } //pipe.Exit(); //} }
private static string RunPropertyBagTest(string input) { using (var context = ZmqContext.Create()) { Pipe pipe = new Pipe(); pipe.Start(context); using (var actor = new Actor(context)) { //actor.RegisterActor("Basic", "85308", (Message, InRoute) => // { // Console.WriteLine(Message); // }); //actor.StartAllActors(); var serializer = new TestHelpers.Serializer(Encoding.Unicode); string expectedAddress = "XXXX"; actor.RegisterActor <Customer>("Basic", expectedAddress, "OutRoute", serializer, (Message, InRoute, OutRoute, Socket, Actor) => { var customer = (Customer)Message; //Console.WriteLine(customer.Firstname + " " + customer.Lastname); if (!Actor.PropertyBag.ContainsKey("Count")) { Actor.PropertyBag.Add("Count", "0"); } var count = int.Parse(Actor.PropertyBag["Count"]); count++; Actor.PropertyBag["Count"] = count.ToString(); Helper.Writeline(customer.Firstname + " " + customer.Lastname + " Count:" + count.ToString()); }); actor.StartAllActors(); while (input != "exit") { input = Console.ReadLine(); } } pipe.Exit(); } return(input); }