Exemplo n.º 1
0
 private static void VerifyReply(ReplyData reply)
 {
     if (reply.Size != expectedReply.Size)
     {
         throw new InvalidOperationException();
     }
 }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            inputData = new InputData
            {
                Content = new byte[1]
            };
            new Random().NextBytes(inputData.Content);
            expectedReply = ServerLogic.Convert(inputData);

            string ipcMethod;

            if (args.Length > 0)
            {
                ipcMethod = args[0];
            }
            else
            {
                Console.Write("Please specify IPC client method to use: ");
                ipcMethod = Console.ReadLine();
            }
            switch (ipcMethod)
            {
            case "wcf":
                Test <WcfClient>();
                break;

            case "wcftcp":
                Test <WcfTcpClient>();
                break;

            case "udp":
                Test <UdpClient>();
                break;

            case "tcp":
                Test <TcpClient>();
                break;

            case "pipe":
                Test <NamedPipeClient>();
                break;

            case "mmf":
                Test <MmfClient>();
                break;

            case "zeromq":
                Test <ZeroMqClient>();
                break;

            case "rabbitmq":
                Test <RabbitMqClient>();
                break;
            }
            Console.WriteLine("Client test completed.");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        public static ReplyData Convert(InputData data)
        {
            var reply = new ReplyData
            {
                Size = data.Content.LongLength
            };

            return(reply);
        }
Exemplo n.º 4
0
 private void HandleEtwEvent(TraceEvent eventData)
 {
     if ((int)eventData.ID == EtwSource.ReplyEventId)
     {
         var data = eventData.PayloadByName("data") as byte[];
         replyData = data.ConvertTo <ReplyData>();
         replyReceived.Set();
     }
 }
Exemplo n.º 5
0
        public ReplyData GetReply(InputData data)
        {
            reply = null;
            var corrId = Guid.NewGuid().ToString();
            var props  = channel.CreateBasicProperties();

            props.ReplyTo       = replyQueueName;
            props.CorrelationId = corrId;

            var messageBytes = ByteArray.CreateFrom(data);

            channel.BasicPublish(exchange: "",
                                 routingKey: "rpc_queue",
                                 basicProperties: props,
                                 body: messageBytes);

            replyReady.WaitOne();
            return(reply);
        }
Exemplo n.º 6
0
        public RabbitMqClient()
        {
            var factory = new ConnectionFactory()
            {
                HostName = Program.ServerIP
            };

            connection         = factory.CreateConnection();
            channel            = connection.CreateModel();
            replyQueueName     = channel.QueueDeclare().QueueName;
            consumer           = new EventingBasicConsumer(channel);
            consumer.Received += (model, ea) =>
            {
                reply = ea.Body.ConvertTo <ReplyData>();
                replyReady.Set();
            };
            channel.BasicConsume(queue: replyQueueName,
                                 noAck: true,
                                 consumer: consumer);
        }
Exemplo n.º 7
0
        private static void Main(string[] args)
        {
            inputData = new InputData
            {
                Content = new byte[100 * 1024]
            };
            new Random().NextBytes(inputData.Content);
            expectedReply = ServerLogic.Convert(inputData);

            string ipcMethod;

            if (args.Length > 0)
            {
                ipcMethod = args[0];
            }
            else
            {
                Console.Write("Please specify IPC client method to use: ");
                ipcMethod = Console.ReadLine();
            }
            switch (ipcMethod)
            {
            case "noipc":
                var inputBuf = ByteArray.CreateFrom(inputData);
                var input    = inputBuf.ConvertTo <InputData>();
                var reply    = ServerLogic.Convert(input);
                var replyBuf = ByteArray.CreateFrom(reply);
                VerifyReply(replyBuf.ConvertTo <ReplyData>());
                break;

            case "wcf":
                Test <WcfClient>();
                break;

            case "wcftcp":
                Test <WcfTcpClient>();
                break;

            case "udp":
                Test <UdpClient>();
                break;

            case "tcp":
                Test <TcpClient>();
                break;

            case "remoting":
                Test <RemotingClient>();
                break;

            case "mq":
                Test <MessageQueueClient>();
                break;

            case "pipe":
                Test <NamedPipeClient>();
                break;

            case "mmf":
                Test <MmfClient>();
                break;

            case "etw":
                Test <EtwClient>();
                break;

            case "wmcopydata":
                Test <WmCopyDataClient>();
                break;

            case "zeromq":
                Test <ZeroMqClient>();
                break;

            case "rabbitmq":
                Test <RabbitMqClient>();
                break;

            case "webapi":
                Test <WebApiClient>();
                break;
            }
            Console.WriteLine("Client test completed.");
            Console.ReadLine();
        }