Exemple #1
0
        private void EchoClient(IMDPClient client, string serviceName)
        {
            var request = new NetMQMessage();

            // set the request data
            request.Push("Helo World!");
            // send the request to the service
            var reply = client.Send(serviceName, request);

            Assert.That(reply, Is.Not.Null, "[ECHO CLIENT] REPLY was <null>");
            Assert.That(reply.FrameCount, Is.EqualTo(1));
            Assert.That(reply.First.ConvertToString(), Is.EqualTo("Helo World!"));
        }
Exemple #2
0
        private void AddHelloClient(IMDPClient client, string serviceName)
        {
            const string _PAYLOAD = "Hello World";
            var          request  = new NetMQMessage();

            // set the request data
            request.Push(_PAYLOAD);
            // send the request to the service
            var reply = client.Send(serviceName, request);

            Assert.That(reply, Is.Not.Null, "[ADD HELLO CLIENT] REPLY was <null>");
            Assert.That(reply.FrameCount, Is.EqualTo(1));
            Assert.That(reply.First.ConvertToString(), Is.EqualTo(_PAYLOAD + " - HELLO"));
        }
        private Tuple <NetMQMessage, TitanicReturnCode> ServiceCall(IMDPClient session, TitanicOperation op, NetMQMessage message)
        {
            // message can be:
            //  REQUEST:
            //      in goes -> [titanic operation][service requested][request]
            //      returns -> [return code][Guid]
            //  REPLY
            //      in goes -> [titanic operation][request id]
            //      returns -> [return code][reply]
            //  CLOSE
            //      in goes -> [titanic operation][request id]
            var reply = session.Send(op.ToString(), message);

            Log(string.Format("received message: {0}", reply));

            if (ReferenceEquals(reply, null) || reply.IsEmpty)
            {
                return(null); // went wrong - why? I don't care!
            }
            // we got a reply -> [return code][data]
            var rc     = reply.Pop().ConvertToString();     // [return code] <- [data] or [service name] if 'Unknown'
            var status = (TitanicReturnCode)Enum.Parse(typeof(TitanicReturnCode), rc);

            switch (status)
            {
            case TitanicReturnCode.Ok:
                return(new Tuple <NetMQMessage, TitanicReturnCode> (reply, TitanicReturnCode.Ok));

            case TitanicReturnCode.Pending:
                return(new Tuple <NetMQMessage, TitanicReturnCode> (reply, TitanicReturnCode.Pending));

            case TitanicReturnCode.Unknown:
                Log("ERROR: Service unknown!");
                return(new Tuple <NetMQMessage, TitanicReturnCode> (reply, TitanicReturnCode.Unknown));

            default:
                Log("ERROR: FATAL ERROR ABANDONING!");
                return(new Tuple <NetMQMessage, TitanicReturnCode> (null, TitanicReturnCode.Failure));
            }
        }
Exemple #4
0
        private void MultipleRequestClient(string serviceName, string endpoint, IMDPClient client = null)
        {
            const int _NO_OF_RUNS = 100;

            var reply = new NetMQMessage[_NO_OF_RUNS];
            var idC01 = new[] { (byte)'C', (byte)'1' };

            client = client ?? new MDPClient(endpoint, idC01);

            var request = new NetMQMessage();

            // set the request data
            request.Push("Helo World!");
            // send the request to the service
            for (int i = 0; i < _NO_OF_RUNS; i++)
            {
                reply[i] = client.Send(serviceName, request);
            }

            client.Dispose();

            Assert.That(reply, Has.None.Null);
            Assert.That(reply.All(r => r.First.ConvertToString() == "Helo World!"));
        }
        private void AddHelloClient(IMDPClient client, string serviceName)
        {
            const string _PAYLOAD = "Hello World";
            var request = new NetMQMessage();
            // set the request data
            request.Push(_PAYLOAD);
            // send the request to the service
            var reply = client.Send(serviceName, request);

            Assert.That(reply, Is.Not.Null, "[ADD HELLO CLIENT] REPLY was <null>");
            Assert.That(reply.FrameCount, Is.EqualTo(1));
            Assert.That(reply.First.ConvertToString(), Is.EqualTo(_PAYLOAD + " - HELLO"));
        }
        private void MultipleRequestClient(string serviceName, string endpoint, IMDPClient client = null)
        {
            const int _NO_OF_RUNS = 100;

            var reply = new NetMQMessage[_NO_OF_RUNS];
            var idC01 = new[] { (byte)'C', (byte)'1' };

            client = client ?? new MDPClient(endpoint, idC01);

            var request = new NetMQMessage();
            // set the request data
            request.Push("Helo World!");
            // send the request to the service
            for (int i = 0; i < _NO_OF_RUNS; i++)
                reply[i] = client.Send(serviceName, request);

            client.Dispose();

            Assert.That(reply, Has.None.Null);
            Assert.That(reply.All(r => r.First.ConvertToString() == "Helo World!"));
        }
        private void EchoClient(IMDPClient client, string serviceName)
        {
            var request = new NetMQMessage();
            // set the request data
            request.Push("Helo World!");
            // send the request to the service
            var reply = client.Send(serviceName, request);

            Assert.That(reply, Is.Not.Null, "[ECHO CLIENT] REPLY was <null>");
            Assert.That(reply.FrameCount, Is.EqualTo(1));
            Assert.That(reply.First.ConvertToString(), Is.EqualTo("Helo World!"));
        }