public static void Main() { var options = new TypedSocketOptions(); options.AnswerTimeout = TimeSpan.FromSeconds(600); var socket = new TypedHyperSocket(options, new DefaultTypedHandlerFactory(), new JsonTransportSerializer()); socket.Register <TestMessage>(IncomingTestMessage); socket.Connect(IPAddress.Parse("127.0.0.1"), 8900); for (int i = 0; i < 100; i++) { string message = "Message from BindProgram " + i; // Asynchronous Console.WriteLine(DateTime.Now + " SENDING MESSAGE (NONBLOCKING): " + message); socket.Send <TestMessage, TestMessage>(new TestMessage { Message = message }, AnswerCallback); // Blocking // By default batching is turned on with a timeout period of 1 second, this will throttle the speed in this demo // To change this behaviour send custom settings into TypedUnicastSocket constructor Console.WriteLine(DateTime.Now + " SENDING MESSAGE (BLOCKING) : " + message); IAnswerable <TestMessage> reply = socket.Send <TestMessage, TestMessage>(new TestMessage { Message = message }); Console.WriteLine("RECEIVED ANSWER (BLOCKING): " + reply.Message.Message); } Console.WriteLine("Waiting for messages (Press enter to continue)..."); Console.ReadLine(); }
public static void Main() { var options = new TypedSocketOptions(); options.AnswerTimeout = TimeSpan.FromSeconds(600); var socket = new TypedHyperSocket(options, new DefaultTypedHandlerFactory(), new JsonTransportSerializer()); socket.Register<TestMessage>(IncomingTestMessage); socket.Connect(IPAddress.Parse("127.0.0.1"), 8900); for(int i = 0; i < 100; i++) { string message = "Message from BindProgram " + i; // Asynchronous Console.WriteLine(DateTime.Now + " SENDING MESSAGE (NONBLOCKING): " + message); socket.Send<TestMessage, TestMessage>(new TestMessage {Message = message}, AnswerCallback); // Blocking // By default batching is turned on with a timeout period of 1 second, this will throttle the speed in this demo // To change this behaviour send custom settings into TypedUnicastSocket constructor Console.WriteLine(DateTime.Now + " SENDING MESSAGE (BLOCKING) : " + message); IAnswerable<TestMessage> reply = socket.Send<TestMessage, TestMessage>(new TestMessage {Message = message}); Console.WriteLine("RECEIVED ANSWER (BLOCKING): " + reply.Message.Message); } Console.WriteLine("Waiting for messages (Press enter to continue)..."); Console.ReadLine(); }
public static void Main() { var socket = new TypedHyperSocket(new DefaultTypedHandlerFactory(), new JsonTransportSerializer()); socket.Register <TestMessage, MessageHandler>(); socket.Bind(IPAddress.Any, 8900); Console.WriteLine("Waiting for messages (Press enter to continue)..."); Console.ReadLine(); }