public string Connect(string address, int port) { if (Client != null && Client.State == CommunicationState.Opened) { Client.Abort(); } Client = new ServiceManagerClient(address, port); try { Client.RegisterClient(); } catch (EndpointNotFoundException) { return("%!Unable to connect to " + address + ":" + port); } Client.Disconnected += OnServiceDisconnected; Client.NotificationReceived += OnNotificationReceived; Client.ExtensionNotificationReceived += OnExtensionNotificationReceived; var dt = Client.GetServerTime(); return("%~Connected. Server time is " + dt + "."); }
public string Connect(string address, int port) { if(Client != null && Client.State == CommunicationState.Opened) Client.Abort(); Client = new ServiceManagerClient(address, port); try { Client.RegisterClient(); } catch(EndpointNotFoundException) { return "%!Unable to connect to " + address + ":" + port; } Client.Disconnected += OnServiceDisconnected; Client.NotificationReceived += OnNotificationReceived; Client.ExtensionNotificationReceived += OnExtensionNotificationReceived; var dt = Client.GetServerTime(); return "%~Connected. Server time is " + dt + "."; }