private void HandleResume(bool automatic) { if (_sleep) { _sleep = false; _away = false; // DeInitialize when resuming to make sure client is prepared properly. if (_client != null) { _client.DeInit(); _client = null; } } if (_client == null) { _config = null; PrepareClient(); } if (automatic) { Thread resumeThread = new Thread(new ThreadStart(_client.OnResumeByAutomatic)); resumeThread.Name = "CECResA"; resumeThread.Start(); } else { Thread resumeThread = new Thread(new ThreadStart(_client.OnResumeByUser)); resumeThread.Name = "CECResU"; resumeThread.Start(); } }
public void Stop() { Log.Info("CecRemote: Closing connection to client..."); if (_client == null) { Log.Info("CecRemote: Client already closed. Plugin exit."); return; } _client.OnStop(); _client = null; _config = null; Log.Info("CecRemote: Plugin exit."); }
private void PrepareClient() { if (_client == null) { _client = new CecRemoteClient(); } if (_config == null) { _config = new CecConfig(); try { _config.ReadConfig(); _client.SetConfig(_config); } catch (Exception ex) { Log.Error("CecRemote: Error while reading config. " + ex.ToString()); // Defaults will be used automatically if config reading fails, so we can still try to connect. } } }