示例#1
0
        public AsyncReqReplyServiceSpecs()
        {
            Reply   = string.Empty;
            Replied = new ManualResetEvent(false);
            Console.WriteLine("Start client fiber");
            Func <byte[], string> unmarshaller = x => Encoding.Unicode.GetString(x);
            Func <string, byte[]> marshaller   = x => Encoding.Unicode.GetBytes(x);

            ServerFiber   = PoolFiber.StartNew();
            ServerContext = NetMQContext.Create();
            Service       = new AsyncRequestHandlerSocket <string, string>(ServerContext,
                                                                           "tcp://localhost:9997",
                                                                           unmarshaller,
                                                                           marshaller);
            Service.SetRequestHandler(ServerFiber, request => request.Reply(request.Request.ToUpper()));
            Console.WriteLine("Start service");
            ClientFiber = StubFiber.StartNew();

            ClientContext = NetMQContext.Create();
            Client        = new AsyncRequestSocket <string, string>(ClientContext,
                                                                    "tcp://localhost:9997",
                                                                    marshaller,
                                                                    unmarshaller);
            Console.WriteLine("Start client");
        }
示例#2
0
        public AsyncReqReplyServiceSpecs()
        {
            Reply = string.Empty;
            Replied = new ManualResetEvent(false);
            Console.WriteLine("Start client fiber");
            Func<byte[], string> unmarshaller = x => Encoding.Unicode.GetString(x);
            Func<string, byte[]> marshaller = x => Encoding.Unicode.GetBytes(x);
            ServerFiber = PoolFiber.StartNew();
            ServerContext = NetMQContext.Create();
            Service = new AsyncRequestHandlerSocket<string, string>(ServerContext,
                "tcp://localhost:9997",
                unmarshaller,
                marshaller);
            Service.SetRequestHandler(ServerFiber, request => request.Reply(request.Request.ToUpper()));
            Console.WriteLine("Start service");
            ClientFiber = StubFiber.StartNew();

            ClientContext = NetMQContext.Create();
            Client = new AsyncRequestSocket<string, string>(ClientContext,
                "tcp://localhost:9997",
                marshaller,
                unmarshaller);
            Console.WriteLine("Start client");
        }