本文整理汇总了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();
}
示例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();
}