当前位置: 首页>>代码示例>>C#>>正文


C# IServiceClient.Disconnect方法代码示例

本文整理汇总了C#中IServiceClient.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceClient.Disconnect方法的具体用法?C# IServiceClient.Disconnect怎么用?C# IServiceClient.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceClient的用法示例。


在下文中一共展示了IServiceClient.Disconnect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        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();
        }
开发者ID:GodLesZ,项目名称:ZeusEngine,代码行数:30,代码来源:Program.cs

示例2: Main

        public static void Main(string[] args)
        {
            var serverConfiguration = Factory.Create<Provider>("conf/client.xml");
            var dynamicConfig = serverConfiguration.FirstAsExpando().configuration;

            string address = string.Format("tcp://{0}:{1}", dynamicConfig.zeus.host, dynamicConfig.zeus.port);
            var endPoint = ProtocolEndPointBase.CreateEndPoint(address);

            _service = ServiceClientBuilder.CreateClient<IClientService>(endPoint);
            _service.Connected += (o, a) => Console.WriteLine("Connection to auth-server successfull!");
            _service.Disconnected += (o, a) => Console.WriteLine("Connection to inter-server lost.");
            _service.ConnectTimeout = 30;
            _service.Connect();

            do {

                var cmd = Console.ReadLine();
                if (cmd == "exit") {
                    _service.Disconnect();
                }
                if (cmd == "login") {
                    var account = _service.ServiceProxy.ClientLogin("test", "test");
                    Console.WriteLine("Got account info: {0}", account);
                }
                if (cmd == "servers") {
                    var servers = _service.ServiceProxy.GetServerDescriptions();
                    Console.WriteLine("Got server info:");
                    servers.ToList().ForEach(s => Console.WriteLine("\t{0}", s));
                }

            } while (_service.CommunicationState == CommunicationStates.Connected);

            Console.WriteLine("Press any key to exit.");
            Console.Read();
        }
开发者ID:GodLesZ,项目名称:ZeusEngine,代码行数:35,代码来源:Program.cs


注:本文中的IServiceClient.Disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。