Beispiel #1
0
        private static void OnExit(object sender, EventArgs e)
        {
            // Clear tray icon on close
            if (TrayIcon != null)
            {
                TrayIcon.Visible = false;
            }

            // On send clear priority
            if (_protoClient != null)
            {
                _captureEnabled = false;
                ProtoClient.ClearPriority(Settings.HyperionMessagePriority);
                Thread.Sleep(50);
                ProtoClient.ClearPriority(Settings.HyperionMessagePriority);
                ProtoClient.Disconnect();
            }

            if (Settings.ApiEnabled)
            {
                _apiServer.StopServer();
            }

            Environment.Exit(0);
        }
 private static void DisconnectProtoClient()
 {
     ProtoClient.Disconnect();
     Thread.Sleep(500);
     TrayIcon.Text = AppConstants.TRAY_ICON_MSG_NOT_CONNECTED;
     LOG.Info("Proto Client disconnect action completed");
 }
 private static void InitProtoClient()
 {
     if (ProtoClient.IsConnected())
     {
         // Proto client already initialized
         return;
     }
     try
     {
         LOG.Info("Initializing Proto Client");
         ProtoClient.Disconnect();
         ProtoClient.Init(SettingsManager.HyperionServerIp, SettingsManager.HyperionServerPort, SettingsManager.HyperionMessagePriority);
         // Double checking since sometimes exceptions are not thrown even if connection fails
         if (ProtoClient.IsConnected())
         {
             LOG.Info("Proto Client initialized");
             NotificationUtils.Info($"Connected to Hyperion server on {SettingsManager.HyperionServerIp}:{SettingsManager.HyperionServerPort}!");
         }
         else
         {
             throw new Exception(GetProtoInitFailedMsg());
         }
     }
     catch (Exception ex)
     {
         throw new Exception(GetProtoInitFailedMsg(), ex);
     }
 }
Beispiel #4
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;
            }
        }
Beispiel #5
0
        void OnExit
            (object sender, EventArgs e)
        {
            // Clear tray icon on close
            if (TrayIcon != null)
            {
                TrayIcon.Visible = false;
            }

            // On send clear priority
            if (_protoClient != null)
            {
                CaptureEnabled = false;
                _protoClient.ClearPriority(HyperionMessagePriority);
                Thread.Sleep(50);
                _protoClient.ClearPriority(HyperionMessagePriority);
                _protoClient.Disconnect();
            }

            Application.Exit();
        }