Beispiel #1
0
        public bool Start()
        {
            try
            {
                if (!IsActive)
                {
                    #region WCF client

                    var address = new EndpointAddress(new Uri("net.tcp://localhost:26760/ScpRootHubService"));
                    var binding = new NetTcpBinding
                    {
                        TransferMode = TransferMode.Streamed,
                        Security     = new NetTcpSecurity {
                            Mode = SecurityMode.None
                        }
                    };
                    var factory = new ChannelFactory <IScpCommandService>(binding, address);

                    _rootHub = factory.CreateChannel(address);

                    #endregion

                    #region Feed client

                    var rootHubFeedChannel = new ScpNativeFeedChannel(_rxFeedClient);
                    rootHubFeedChannel.Receiver.SubscribeOn(TaskPoolScheduler.Default).Subscribe(buffer =>
                    {
                        if (buffer.Length <= 0)
                        {
                            return;
                        }

                        OnFeedPacketReceived(new ScpHidReport(buffer));
                    });

                    _rxFeedClient.ConnectAsync();

                    #endregion

                    if (_rootHub != null)
                    {
                        _xmlMap.LoadXml(_rootHub.GetXml());
                        _xmlMapper.Initialize(_xmlMap);
                    }
                    else
                    {
                        Log.Error("Couldn't initialize XML mapper");
                    }

                    IsActive = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return(IsActive);
        }
Beispiel #2
0
        public bool Start()
        {
            try
            {
                if (!IsActive)
                {
                    #region WCF client

                    var address = new EndpointAddress(new Uri("net.tcp://localhost:26760/ScpRootHubService"));
                    var binding = new NetTcpBinding
                    {
                        TransferMode = TransferMode.Streamed,
                        Security     = new NetTcpSecurity {
                            Mode = SecurityMode.None
                        }
                    };
                    var factory = new ChannelFactory <IScpCommandService>(binding, address);

                    _rootHub = factory.CreateChannel(address);

                    #endregion

                    #region Feed client

                    var rootHubFeedChannel = new ScpNativeFeedChannel(_rxFeedClient);
                    rootHubFeedChannel.Receiver.SubscribeOn(TaskPoolScheduler.Default).Subscribe(buffer =>
                    {
                        if (buffer.Length <= 0)
                        {
                            return;
                        }
                        ScpHidReport report;
                        using (var ms = new MemoryStream(buffer))
                        {
                            BinaryFormatter formatter = new BinaryFormatter();
                            report = (ScpHidReport)formatter.Deserialize(ms);
                        }
                        OnFeedPacketReceived(report);
                    });

                    _rxFeedClient.ConnectAsync();

                    #endregion

                    IsActive = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return(IsActive);
        }
Beispiel #3
0
        public bool Start()
        {
            try
            {
                if (!IsActive)
                {
                    #region WCF client

                    var address = new EndpointAddress(new Uri("net.tcp://localhost:26760/ScpRootHubService"));
                    var binding = new NetTcpBinding
                    {
                        TransferMode = TransferMode.Streamed,
                        Security = new NetTcpSecurity {Mode = SecurityMode.None}
                    };
                    var factory = new ChannelFactory<IScpCommandService>(binding, address);

                    _rootHub = factory.CreateChannel(address);

                    #endregion

                    #region Feed client

                    var rootHubFeedChannel = new ScpNativeFeedChannel(_rxFeedClient);
                    rootHubFeedChannel.Receiver.SubscribeOn(TaskPoolScheduler.Default).Subscribe(buffer =>
                    {
                        if (buffer.Length <= 0)
                            return;

                        OnFeedPacketReceived(new ScpHidReport(buffer));
                    });

                    _rxFeedClient.ConnectAsync();

                    #endregion

                    IsActive = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return IsActive;
        }
Beispiel #4
0
        public bool Start()
        {
            try
            {
                if (!m_Active)
                {
                    #region WCF client

                    var address = new EndpointAddress(new Uri("net.tcp://localhost:26760/ScpRootHubService"));
                    var binding = new NetTcpBinding();
                    var factory = new ChannelFactory<IScpCommandService>(binding, address);

                    _rootHub = factory.CreateChannel(address);

                    #endregion

                    #region Feed client

                    var rootHubFeedChannel = new ScpNativeFeedChannel(_rxFeedClient);
                    rootHubFeedChannel.Receiver.SubscribeOn(TaskPoolScheduler.Default).Subscribe(buffer =>
                    {
                        if (buffer.Length <= 0)
                            return;

                        var packet = new DsPacket();

                        OnFeedPacketReceived(packet.Load(buffer));
                    });

                    _rxFeedClient.ConnectAsync();

                    #endregion

                    if (_rootHub != null)
                    {
                        _xmlMap.LoadXml(_rootHub.GetXml());
                        _xmlMapper.Initialize(_xmlMap);
                    }
                    else
                    {
                        Log.Error("Couldn't initialize XML mapper");
                    }

                    m_Active = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return m_Active;
        }
Beispiel #5
0
        public bool Start()
        {
            try
            {
                if (!m_Active)
                {
                    var address = new EndpointAddress(new Uri("net.tcp://localhost:26760/ScpRootHubService"));
                    var binding = new NetTcpBinding();
                    var factory = new ChannelFactory<IScpCommandService>(binding, address);
                    _rootHub = factory.CreateChannel(address);

                    m_Active = true;
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Unexpected error: {0}", ex);
            }

            return m_Active;
        }