public void Connect(string serverAddress, int serverPort) { try { HsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverAddress, serverPort), this); HsClient.Connect(); HS = HsClient.ServiceProxy; var apiVersion = HS.APIVersion; // just to make sure our connection is valid hsTraceListener = new HSTraceListener(this as IDebugLogger); Debug.Listeners.Add(hsTraceListener); this.Log.HS = HS; } catch (Exception ex) { throw new HspiConnectionException( String.Format(CultureInfo.InvariantCulture, "Error connecting homeseer SCS client: {0}", ex.GetFullMessage()), ex ); } try { CallbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverAddress, serverPort), this); CallbackClient.Connect(); Callback = CallbackClient.ServiceProxy; var apiVersion = Callback.APIVersion; // just to make sure our connection is valid } catch (Exception ex) { throw new HspiConnectionException( String.Format(CultureInfo.InvariantCulture, "Error connecting callback SCS client: {0}", ex.GetFullMessage()), ex ); } // Establish the reverse connection from homeseer back to our plugin try { HS.Connect(Name, InstanceFriendlyName()); } catch (Exception ex) { throw new HspiConnectionException( String.Format(CultureInfo.InvariantCulture, "Error connecting homeseer to our plugin: {0}", ex.GetFullMessage()), ex ); } HsClient.Disconnected += HsClient_Disconnected; }
public void Connect(string serverAddress, int serverPort) { Trace.WriteLine(Invariant($"Connecting to {serverAddress}")); try { HsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverAddress, serverPort), this); HsClient.Connect(); HS = HsClient.ServiceProxy; #pragma warning disable S1481 // Unused local variables should be removed var apiVersion = HS.APIVersion; // just to make sure our connection is valid #pragma warning restore S1481 // Unused local variables should be removed hsTraceListener = new HSTraceListener(this as ILogger); Debug.Listeners.Add(hsTraceListener); } catch (Exception ex) { throw new HspiConnectionException(Invariant($"Error connecting homeseer SCS client: {ex.GetFullMessage()}"), ex); } try { CallbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(new ScsTcpEndPoint(serverAddress, serverPort), this); CallbackClient.Connect(); Callback = CallbackClient.ServiceProxy; #pragma warning disable S1481 // Unused local variables should be removed var apiVersion = Callback.APIVersion; // just to make sure our connection is valid #pragma warning restore S1481 // Unused local variables should be removed } catch (Exception ex) { throw new HspiConnectionException(Invariant($"Error connecting callback SCS client: {ex.GetFullMessage()}"), ex); } // Establish the reverse connection from homeseer back to our plugin try { HS.Connect(Name, InstanceFriendlyName()); } catch (Exception ex) { throw new HspiConnectionException(Invariant($"Error connecting homeseer to our plugin: {ex.GetFullMessage()}"), ex); } HsClient.Disconnected += HsClient_Disconnected; Trace.WriteLine(Invariant($"Connected to {serverAddress}")); }