// ======================= HELPER ========================= private void EchoWorker(IMDPWorker worker, int heartbeatinterval = 2500) { worker.HeartbeatDelay = TimeSpan.FromMilliseconds(heartbeatinterval); // send the reply and wait for a request var request = worker.Receive(null); // was the worker interrupted Assert.That(request, Is.Not.Null); // echo the request and wait for next request which will not come // here the task will be canceled var newrequest = worker.Receive(request); }
private void DoubleEchoWorker(IMDPWorker worker, int heartbeatinterval = 2500) { worker.HeartbeatDelay = TimeSpan.FromMilliseconds(heartbeatinterval); var request = worker.Receive(null); // was the worker interrupted Assert.That(request, Is.Not.Null); // double the content of the request var payload = request.Last.ConvertToString(); payload += " - " + payload; request.RemoveFrame(request.Last); request.Append(payload); // echo the request and wait for next request which will not come // here the task will be canceled var newrequest = worker.Receive(request); }
private static void AddHelloWorker(IMDPWorker worker, int heartbeatinterval = 2500) { worker.HeartbeatDelay = TimeSpan.FromMilliseconds(heartbeatinterval); // send the reply and wait for a request var request = worker.Receive(null); // was the worker interrupted Assert.That(request, Is.Not.Null); // add the extra the content to request var payload = request.Last.ConvertToString(); payload += " - HELLO"; request.RemoveFrame(request.Last); request.Append(payload); // echo the request and wait for next request which will not come // here the task will be canceled var newrequest = worker.Receive(request); }
private static void MultipleRequestWorker(IMDPWorker worker = null, string endpoint = null, int heartbeatinterval = 2500) { var idW01 = new[] { (byte)'W', (byte)'1' }; worker = worker ?? new MDPWorker(endpoint, "echo", idW01); worker.HeartbeatDelay = TimeSpan.FromMilliseconds(heartbeatinterval); NetMQMessage reply = null; while (true) { // send the reply and wait for a request var request = worker.Receive(reply); // was the worker interrupted Assert.That(request, Is.Not.Null); // echo the request and wait for next request which will not come // here the task will be canceled reply = worker.Receive(request); } }
private void AddHelloWorker(IMDPWorker worker, int heartbeatinterval = 2500) { worker.HeartbeatDelay = TimeSpan.FromMilliseconds(heartbeatinterval); // send the reply and wait for a request var request = worker.Receive(null); // was the worker interrupted Assert.That(request, Is.Not.Null); // add the extra the content to request var payload = request.Last.ConvertToString(); payload += " - HELLO"; request.RemoveFrame(request.Last); request.Append(payload); // echo the request and wait for next request which will not come // here the task will be canceled var newrequest = worker.Receive(request); }
private void MultipleRequestWorker(IMDPWorker worker = null, string endpoint = null, int heartbeatinterval = 2500) { var idW01 = new[] { (byte)'W', (byte)'1' }; worker = worker ?? new MDPWorker(endpoint, "echo", idW01); worker.HeartbeatDelay = TimeSpan.FromMilliseconds(heartbeatinterval); NetMQMessage reply = null; while (true) { // send the reply and wait for a request var request = worker.Receive(reply); // was the worker interrupted Assert.That(request, Is.Not.Null); // echo the request and wait for next request which will not come // here the task will be canceled reply = worker.Receive(request); } }
private static void DoubleEchoWorker (IMDPWorker worker, int heartbeatinterval = 2500) { worker.HeartbeatDelay = TimeSpan.FromMilliseconds (heartbeatinterval); var request = worker.Receive (null); // was the worker interrupted Assert.That (request, Is.Not.Null); // double the content of the request var payload = request.Last.ConvertToString (); payload += " - " + payload; request.RemoveFrame (request.Last); request.Append (payload); // echo the request and wait for next request which will not come // here the task will be canceled var newrequest = worker.Receive (request); }