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); }
protected virtual void NativeFeed_Worker_DoWork(object sender, DoWorkEventArgs e) { DsPacket Packet = new DsPacket(); Byte[] Buffer = new Byte[ReportEventArgs.Length]; while (!NativeFeed_Worker.CancellationPending) { try { m_Client.Client.Receive(Buffer); LogPacket(Packet.Load(Buffer)); } catch { } } m_Client.Close(); e.Cancel = true; }