コード例 #1
0
        private void ensureConnection()
        {
            if (_htsConnection == null)
            {
                return;
            }

            if (_htsConnection.needsRestart())
            {
                createHTSConnection();
            }

            lock (_htsConnection)
            {
                if (!_connected)
                {
                    var config = Plugin.Instance.Configuration;

                    if (string.IsNullOrEmpty(config.TVH_ServerName))
                    {
                        string message = "[TVHclient] LiveTvService.ensureConnection: TVH-Server name must be configured.";
                        _logger.Error(message);
                        throw new InvalidOperationException(message);
                    }

                    if (string.IsNullOrEmpty(config.Username))
                    {
                        string message = "[TVHclient] LiveTvService.ensureConnection: Username must be configured.";
                        _logger.Error(message);
                        throw new InvalidOperationException(message);
                    }

                    if (string.IsNullOrEmpty(config.Password))
                    {
                        string message = "[TVHclient] LiveTvService.ensureConnection: Password must be configured.";
                        _logger.Error(message);
                        throw new InvalidOperationException(message);
                    }

                    _priority = config.Priority;
                    _profile  = config.Profile;

                    if (_priority < 0 || _priority > 4)
                    {
                        _priority = 2;
                        _logger.Info("[TVHclient] LiveTvService.ensureConnection: Priority was out of range [0-4] - set to 2");
                    }

                    _httpBaseUrl = "http://" + config.TVH_ServerName + ":" + config.HTTP_Port;

                    _htsConnection.open(config.TVH_ServerName, config.HTSP_Port);
                    _connected = _htsConnection.authenticate(config.Username, config.Password);

                    _logger.Info("[TVHclient] LiveTvService.ensureConnection: connection established " + _connected);

                    _channelDataHelper.clean();
                    _dvrDataHelper.clean();
                    _autorecDataHelper.clean();
                }
            }
        }
コード例 #2
0
        private void ensureConnection()
        {
            if (_htsConnection == null)
            {
                return;
            }

            if (_htsConnection.needsRestart())
            {
                createHTSConnection();
            }

            lock (_htsConnection)
            {
                if (!_connected)
                {
                    var config = Plugin.Instance.Configuration;

                    if (string.IsNullOrEmpty(config.TVH_ServerName))
                    {
                        string message = "[TVHclient] LiveTvService.ensureConnection: TVH-Server name must be configured.";
                        _logger.Error(message);
                        throw new InvalidOperationException(message);
                    }

                    if (string.IsNullOrEmpty(config.Username))
                    {
                        string message = "[TVHclient] LiveTvService.ensureConnection: Username must be configured.";
                        _logger.Error(message);
                        throw new InvalidOperationException(message);
                    }

                    if (string.IsNullOrEmpty(config.Password))
                    {
                        string message = "[TVHclient] LiveTvService.ensureConnection: Password must be configured.";
                        _logger.Error(message);
                        throw new InvalidOperationException(message);
                    }

                    _priority = config.Priority;
                    _profile  = config.Profile.Trim();

                    _channelDataHelper.setChannelType4Other(config.ChannelType.Trim());

                    if (_priority < 0 || _priority > 4)
                    {
                        _priority = 2;
                        _logger.Info("[TVHclient] LiveTvService.ensureConnection: Priority was out of range [0-4] - set to 2");
                    }

                    string tvhServerName = config.TVH_ServerName.Trim();
                    int    httpPort      = config.HTTP_Port;
                    int    htspPort      = config.HTSP_Port;
                    string userName      = config.Username.Trim();
                    string password      = config.Password.Trim();

                    _httpBaseUrl = "http://" + tvhServerName + ":" + httpPort;

                    _logger.Info("[TVHclient] LiveTvService.ensureConnection: Used connection parameters: " +
                                 "TVH Server = '" + tvhServerName + "'; " +
                                 "HTTP Port = '" + httpPort + "'; " +
                                 "HTSP Port = '" + htspPort + "'; " +
                                 "User = '******'; " +
                                 "Password set = '" + (password.Length > 0) + "'");

                    _htsConnection.open(tvhServerName, htspPort);
                    _connected = _htsConnection.authenticate(userName, password);

                    _logger.Info("[TVHclient] LiveTvService.ensureConnection: connection established " + _connected);

                    _channelDataHelper.clean();
                    _dvrDataHelper.clean();
                    _autorecDataHelper.clean();
                }
            }
        }