Beispiel #1
0
        /// <summary>
        ///     Opens and initializes devices and services listening and running on the local machine.
        /// </summary>
        /// <returns>True on success, false otherwise.</returns>
        public override bool Open()
        {
            var opened = false;

            Log.Debug("Initializing root hub");

            _limitInstance = new LimitInstance(@"Global\ScpDsxRootHub");

            try
            {
                if (!_limitInstance.IsOnlyInstance) // existing root hub running as desktop app
                    throw new RootHubAlreadyStartedException(
                        "The root hub is already running, please close the ScpServer first!");
            }
            catch (UnauthorizedAccessException) // existing root hub running as service
            {
                throw new RootHubAlreadyStartedException(
                    "The root hub is already running, please stop the ScpService first!");
            }

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                Assembly.GetExecutingAssembly().GetName().Version);
            Log.DebugFormat("++ {0}", OsInfoHelper.OsInfo);

            #region Native feed server

            _rxFeedServer = new ReactiveListener(Settings.Default.RootHubNativeFeedPort);

            _rxFeedServer.Connections.Subscribe(socket =>
            {
                Log.DebugFormat("Client connected on native feed channel: {0}", socket.GetHashCode());
                var protocol = new ScpNativeFeedChannel(socket);

                _nativeFeedSubscribers.Add(socket.GetHashCode(), protocol);

                protocol.Receiver.Subscribe(packet => { Log.Warn("Uuuhh how did we end up here?!"); });

                socket.Disconnected += (sender, e) =>
                {
                    Log.DebugFormat(
                        "Client disconnected from native feed channel {0}",
                        sender.GetHashCode());

                    _nativeFeedSubscribers.Remove(socket.GetHashCode());
                };

                socket.Disposed += (sender, e) =>
                {
                    Log.DebugFormat("Client disposed from native feed channel {0}",
                        sender.GetHashCode());

                    _nativeFeedSubscribers.Remove(socket.GetHashCode());
                };
            });

            #endregion

            opened |= _scpBus.Open(GlobalConfiguration.Instance.Bus);
            opened |= _usbHub.Open();
            opened |= _bthHub.Open();

            GlobalConfiguration.Load();
            return opened;
        }
Beispiel #2
0
        /// <summary>
        ///     Opens and initializes devices and services listening and running on the local machine.
        /// </summary>
        /// <returns>True on success, false otherwise.</returns>
        public override bool Open()
        {
            var opened = false;

            Log.Debug("Initializing root hub");

            _limitInstance = new LimitInstance(@"Global\ScpDsxRootHub");

            try
            {
                if (!_limitInstance.IsOnlyInstance) // existing root hub running as desktop app
                {
                    throw new RootHubAlreadyStartedException(
                              "The root hub is already running, please close the ScpServer first!");
                }
            }
            catch (UnauthorizedAccessException) // existing root hub running as service
            {
                throw new RootHubAlreadyStartedException(
                          "The root hub is already running, please stop the ScpService first!");
            }

            Log.DebugFormat("++ {0} {1}", Assembly.GetExecutingAssembly().Location,
                            Assembly.GetExecutingAssembly().GetName().Version);
            Log.DebugFormat("++ {0}", OsInfoHelper.OsInfo);

            #region Native feed server

            _rxFeedServer = new ReactiveListener(Settings.Default.RootHubNativeFeedPort);

            _rxFeedServer.Connections.Subscribe(socket =>
            {
                Log.DebugFormat("Client connected on native feed channel: {0}", socket.GetHashCode());
                var protocol = new ScpNativeFeedChannel(socket);

                _nativeFeedSubscribers.Add(socket.GetHashCode(), protocol);

                protocol.Receiver.Subscribe(packet => { Log.Warn("Uuuhh how did we end up here?!"); });

                socket.Disconnected += (sender, e) =>
                {
                    Log.DebugFormat(
                        "Client disconnected from native feed channel {0}",
                        sender.GetHashCode());

                    _nativeFeedSubscribers.Remove(socket.GetHashCode());
                };

                socket.Disposed += (sender, e) =>
                {
                    Log.DebugFormat("Client disposed from native feed channel {0}",
                                    sender.GetHashCode());

                    _nativeFeedSubscribers.Remove(socket.GetHashCode());
                };
            });

            #endregion

            opened |= _scpBus.Open(GlobalConfiguration.Instance.Bus);
            opened |= _usbHub.Open();
            opened |= _bthHub.Open();

            GlobalConfiguration.Load();
            return(opened);
        }