Open() public method

public Open ( int instance ) : bool
instance int
return bool
        public virtual Boolean Open()
        {
            bool Opened = false;

            LogDebug(String.Format("++ {0} {1}", Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version.ToString()));
            LogDebug(String.Format("++ {0}", OSInfo()));

            Opened |= scpBus.Open();
            Opened |= usbHub.Open();
            Opened |= bthHub.Open();

            Global.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);
        }
Beispiel #3
0
        public override bool Open()
        {
            var opened = false;

            Log.Info("Initializing root hub");

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

            #region Native feed server

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

                lock (this)
                {
                    _nativeFeedSubscribers.Add(socket.GetHashCode(), protocol);
                }

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

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

                    lock (this)
                    {
                        _nativeFeedSubscribers.Remove(socket.GetHashCode());
                    }
                };

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

                    lock (this)
                    {
                        _nativeFeedSubscribers.Remove(socket.GetHashCode());
                    }
                };
            });

            #endregion

            scpMap.Open();

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

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