public baseobj_stub(WrappedServiceStub innerstub) : base(innerstub)
 {
     rr_cb2 = new CallbackClient <Action <double, double> >("cb2");
     rr_p1  = new Pipe <double[]>(innerstub.GetPipe("p1"));
     rr_w1  = new Wire <double[]>(innerstub.GetWire("w1"));
     rr_m1  = new ArrayMemoryClient <double>(innerstub.GetArrayMemory("m1"));
 }
Exemple #2
0
        private void DisconnectHspiConnection()
        {
            Trace.WriteLine("Disconnecting Hspi Connection");
            cancellationTokenSource.Cancel();

            if (HsClient != null)
            {
                HsClient.Disconnected -= HsClient_Disconnected;
            }

            if (hsTraceListener != null)
            {
                Debug.Listeners.Remove(hsTraceListener);
            }

            if ((CallbackClient != null) &&
                (CallbackClient.CommunicationState == CommunicationStates.Connected))
            {
                CallbackClient.Disconnect();
                CallbackClient = null;
            }

            if ((HsClient != null) &&
                (HsClient.CommunicationState == CommunicationStates.Connected))
            {
                HsClient.Disconnect();
                HsClient = null;
            }

            shutdownWaitEvent.Set();
            Trace.WriteLine("Disconnected Hspi Connection");
        }
 public baseobj_stub(string path, ClientContext c) : base(path, c)
 {
     rr_cb2 = new CallbackClient <Func <double, double, CancellationToken, Task> >("cb2");
     rr_p1  = new PipeClient <double[]>("p1", this);
     rr_w1  = new WireClient <double[]>("w1", this);
     rr_m1  = new ArrayMemoryClient <double>("m1", this, MemberDefinition_Direction.both);
 }
        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;
        }
Exemple #5
0
        public static Ice.DispatchStatus TransHeartbeat___(CallbackClient obj__, IceInternal.Incoming inS__, Ice.Current current__)
        {
            Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode);
            IceInternal.BasicStream is__ = inS__.startReadParams();
            long lTime;

            lTime = is__.readLong();
            inS__.endReadParams();
            obj__.TransHeartbeat(lTime, current__);
            inS__.writeEmptyParams__();
            return(Ice.DispatchStatus.DispatchOK);
        }
Exemple #6
0
 public MainWindow()
 {
     InitializeComponent();
     client                       = new ServiceClient();
     callbackClient               = new CallbackClient(new InstanceContext(new CallbackHandler()));
     ImagesList.ItemsSource       = client.getImagesList();
     ImagesList.SelectionChanged += imagesListSelectionChanged;
     DownloadButton.IsEnabled     = false;
     DownloadButton.Click        += downloadButtonClick;
     DeleteButton.IsEnabled       = false;
     DeleteButton.Click          += deleteButtonClick;
     UploadButton.Click          += uploadButtonClick;
 }
Exemple #7
0
        public void Connect(string serverAddress, int serverPort)
        {
            // This method is called by our console wrapper at launch time

            // Create our main connection to the HomeSeer TCP communication framework
            // part 1 - hs object Proxy
            try
            {
                HsClient =
                    ScsServiceClientBuilder.CreateClient <IHSApplication>(new ScsTcpEndPoint(serverAddress, serverPort),
                                                                          this);
                HsClient.Connect();
                HS = HsClient.ServiceProxy;

                // ReSharper disable once UnusedVariable
                var apiVersion = HS.APIVersion; // just to make sure our connection is valid
            }
            catch (Exception ex)
            {
                throw new HspiConnectionException($"Error connecting HomeSeer SCS client: {ex.Message}", ex);
            }

            // part 2 - callback object Proxy
            try
            {
                CallbackClient =
                    ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(
                        new ScsTcpEndPoint(serverAddress, serverPort), this);
                CallbackClient.Connect();
                Callback = CallbackClient.ServiceProxy;

                // ReSharper disable once UnusedVariable
                var apiVersion = Callback.APIVersion; // just to make sure our connection is valid
            }
            catch (Exception ex)
            {
                throw new HspiConnectionException($"Error connecting callback SCS client: {ex.Message}", ex);
            }

            // Establish the reverse connection from HomeSeer back to our plugin
            try
            {
                HS.Connect(Name, InstanceFriendlyName());
            }
            catch (Exception ex)
            {
                throw new HspiConnectionException($"Error connecting HomeSeer to our plugin: {ex.Message}", ex);
            }
        }
Exemple #8
0
        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}"));
        }
Exemple #9
0
        public static Ice.DispatchStatus TransDataToClient___(CallbackClient obj__, IceInternal.Incoming inS__, Ice.Current current__)
        {
            Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode);
            IceInternal.BasicStream is__ = inS__.startReadParams();
            string strXml;

            strXml = is__.readString();
            inS__.endReadParams();
            int ret__ = obj__.TransDataToClient(strXml, current__);

            IceInternal.BasicStream os__ = inS__.startWriteParams__(Ice.FormatType.DefaultFormat);
            os__.writeInt(ret__);
            inS__.endWriteParams__(true);
            return(Ice.DispatchStatus.DispatchOK);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             if (HsClient != null)
             {
                 HsClient.Disconnected -= HsClient_Disconnected;
                 HsClient.Dispose();
             }
             hsTraceListener?.Dispose();
             CallbackClient?.Dispose();
             cancellationTokenSource.Dispose();
             shutdownWaitEvent.Dispose();
         }
         disposedValue = true;
     }
 }
Exemple #11
0
        static void Main(string[] args)
        {
            NetTcpBinding bindingServer = new NetTcpBinding();
            string        addressServer = "net.tcp://localhost:9999/wcfserver";

            CallbackClient callbackclient = new CallbackClient();
            WCFLocalDB     proxy          = new WCFLocalDB(callbackclient, bindingServer, new EndpointAddress(new Uri(addressServer)));

            callbackclient.Proxy = proxy;

            proxyCaller callerbase = new proxyCaller();

            callerbase.ProxySetter = proxy;

            ////////////////////////////

            callerbase.openNewEndpoint();

            Console.WriteLine("WCFService is opened. Press <enter> to finish...");

            Console.ReadLine();
        }
Exemple #12
0
    public Subscriber(string URI, string playerName) {
        this.URI = URI;
        this.playerName = playerName;
        cbc = new CallbackClient(URI, playerName);

    }
        public bool Connect(string serverAddress = null, int serverPort = -1)
        {
            if (Shutdown)
            {
                return(true);
            }

            if (serverAddress != null)
            {
                // If passed address/port - store it
                // So later may try to reconnect using stored values
                this.serverAddress = serverAddress;
                this.serverPort    = serverPort;
            }

            // Set HS to HsClient.ServiceProxy only when succsessfully finished connecting
            HS = null;

            // Create our main connection to the HomeSeer TCP communication framework
            // part 1 - hs object Proxy
            try
            {
                HsClient = ScsServiceClientBuilder.CreateClient <IHSApplication>(
                    new ScsTcpEndPoint(this.serverAddress, this.serverPort), this);
                HsClient.Disconnected += HsClient_Disconnected;
                HsClient.Connect();
                // Set HS to HsClient.ServiceProxy only when succsessfully finished connecting
                //HS = HsClient.ServiceProxy;

                // just to make sure our connection is valid
                Console.WriteLine("Host ApiVersion : {0}", HsClient.ServiceProxy.APIVersion);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error connecting HomeSeer SCS client: {ex.Message}");
                return(false);
            }

            // part 2 - callback object Proxy
            try
            {
                CallbackClient = ScsServiceClientBuilder.CreateClient <IAppCallbackAPI>(
                    new ScsTcpEndPoint(this.serverAddress, this.serverPort), this);
                CallbackClient.Connect();
                Callback = CallbackClient.ServiceProxy;

                // just to make sure our connection is valid
                Console.WriteLine("Host CB ApiVersion : {0}", Callback.APIVersion);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error connecting callback SCS client: {ex.Message}");
                return(false);
            }

            // part 3 - Establish the reverse connection from HomeSeer back to our plugin
            try
            {
                HsClient.ServiceProxy.Connect(Name, InstanceFriendlyName());
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error connecting HomeSeer to our plugin: {ex.Message}");
                return(false);
            }

            // All good, call virtual Connected() to inform plugin
            HS = HsClient.ServiceProxy;
            Connected(true);
            return(true);
        }