Esempio n. 1
0
        public static void Main(string[] args)
        {
            var endPoint = ProtocolEndPointBase.CreateEndPoint("tcp://127.0.0.1:6900");

            _client = new TestClientImplementation();
            _serviceClient = ServiceClientBuilder.CreateClient<ITestServerService>(endPoint, _client);
            _serviceClient.Connected += ClientOnConnected;
            _serviceClient.Disconnected += ClientOnDisconnected;
            _serviceClient.Connect();

            do {
                var cmd = Console.ReadLine();
                if (cmd == "exit") {
                    _serviceClient.Disconnect();
                }
                if (cmd == "void") {
                    _serviceClient.ServiceProxy.RemoteVoid();
                }
                if (cmd == "magic") {
                    var poco = new SimplePoco {Id = 1, Title = "My POCO obj"};
                    _serviceClient.ServiceProxy.SomeRemoteMagic(poco);
                }
                if (cmd == "ex") {
                    _serviceClient.ServiceProxy.RaiseTheException();
                }
            } while (_serviceClient.CommunicationState == CommunicationStates.Connected);

            Console.WriteLine("Press any key to exit.");
            Console.Read();
        }
Esempio n. 2
0
        /// <summary>
        ///     Invoked by the client including the parameter.
        /// </summary>
        /// <param name="poco"></param>
        public void SomeRemoteMagic(SimplePoco poco)
        {
            ServerConsole.DebugLine("Recv poco obj from client! {0}: {1}", poco.Id, poco.Title);
            Debug.WriteLine(poco);

            // Get client proxy and invoke a answer to the poco
            var proxy = CurrentClient.GetClientProxy<ITestClient>();
            proxy.SomeClientMagic("Got your poco, ty client!");
        }