Example #1
0
        // ======================= 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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
            }
        }
Example #5
0
 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);
 }
Example #6
0
        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);
            }
        }
Example #7
0
        // ======================= 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);
        }
Example #8
0
 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);
 }