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); }
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; }