Exemple #1
0
        public void Init(bool reInit = false, bool forceOn = false)
        {
            LOG.Info($"Initialization requested with parameters reInit={reInit}, forceOn={forceOn}");
            if (_initLock)
            {
                LOG.Info("Initialization already in progress. Ignoring request.");
                return;
            }
            _initLock = true;
            LOG.Info("Initialization lock set");

            // Stop current capture first on reinit
            if (reInit)
            {
                ToggleCapture(CaptureCommand.OFF, false, false);
            }

            if (SettingsManager.CaptureOnStartup || forceOn)
            {
                ToggleCapture(CaptureCommand.ON);
            }

            _apiServer?.StopServer(); // Always stop current server before starting again
            if (SettingsManager.ApiEnabled)
            {
                _apiServer = new ApiServer(this);
                _apiServer.StartServer("+", SettingsManager.ApiPort.ToString());
            }

            _initLock = false;
            LOG.Info("Initialization lock unset");
        }
        private static void ExecuteInitialization(bool reInit, bool forceOn)
        {
            LOG.Info($"Initialization requested with parameters reInit={reInit}, forceOn={forceOn}");
            // Stop current capture first on reinit
            if (reInit)
            {
                TerminateScreenCapture();
                DisconnectProtoClient();
            }

            if (SettingsManager.CaptureOnStartup || forceOn)
            {
                ToggleCapture(CaptureCommand.ON);
            }

            if (SettingsManager.ApiEnabled)
            {
                _apiServer = new ApiServer();
                _apiServer.StartServer("localhost", SettingsManager.ApiPort.ToString());
            }
            else
            {
                _apiServer?.StopServer();
            }
            _initLock = false;
            LOG.Info("Initialization lock unset");
        }
Exemple #3
0
        public static void Init(bool reInit = false, bool forceOn = false)
        {
            if (!_initLock)
            {
                _initLock = true;

                // Stop current capture first on reinit
                if (reInit)
                {
                    _captureEnabled = false;
                    Thread.Sleep(500 + Settings.CaptureInterval);

                    if (_protoClient != null)
                    {
                        ProtoClient.Disconnect();
                        Thread.Sleep(500);
                    }
                }

                _protoClient = new ProtoClient();
                ProtoClient.Init(Settings.HyperionServerIp, Settings.HyperionServerPort,
                                 Settings.HyperionMessagePriority);

                if (Settings.CaptureOnStartup || forceOn)
                {
                    if (ProtoClient.IsConnected())
                    {
                        Notifications.Info($"Connected to Hyperion server on {Settings.HyperionServerIp}!");
                        ToggleCapture("ON");
                    }
                }

                if (Settings.ApiEnabled)
                {
                    _apiServer = new ApiServer();
                    _apiServer.StartServer("localhost", Settings.ApiPort.ToString());
                }
                else
                {
                    _apiServer?.StopServer();
                }

                _initLock = false;
            }
        }