Exemplo n.º 1
0
        //private static Stream ImageToPNGStream(Image image)
        //{
        //    Stream stream = new System.IO.MemoryStream();
        //    image.Save(stream, ImageFormat.Png);
        //    stream.Position = 0;
        //    return stream;
        //}

        private void ensureConnection()
        {
            //_logger.Info("[TVHclient] HTSConnectionHandler.ensureConnection()");
            if (_htsConnection == null || _htsConnection.needsRestart())
            {
                _logger.Info("[TVHclient] HTSConnectionHandler.ensureConnection() : create new HTS-Connection");
                Version version = Assembly.GetEntryAssembly().GetName().Version;
                _htsConnection = new HTSConnectionAsync(this, "TVHclient4Emby-" + version.ToString(), "" + HTSMessage.HTSP_VERSION, _logger);
                _connected     = false;
            }

            lock (_lock)
            {
                if (!_connected)
                {
                    _logger.Info("[TVHclient] HTSConnectionHandler.ensureConnection: Used connection parameters: " +
                                 "TVH Server = '" + _tvhServerName + "'; " +
                                 "HTTP Port = '" + _httpPort + "'; " +
                                 "HTSP Port = '" + _htspPort + "'; " +
                                 "Web-Root = '" + _webRoot + "'; " +
                                 "User = '******'; " +
                                 "Password set = '" + (_password.Length > 0) + "'");

                    _htsConnection.open(_tvhServerName, _htspPort);
                    _connected = _htsConnection.authenticate(_userName, _password);

                    _logger.Info("[TVHclient] HTSConnectionHandler.ensureConnection: connection established " + _connected);
                }
            }
        }
Exemplo n.º 2
0
        //private static Stream ImageToPNGStream(Image image)
        //{
        //    Stream stream = new System.IO.MemoryStream();
        //    image.Save(stream, ImageFormat.Png);
        //    stream.Position = 0;
        //    return stream;
        //}

        private void ensureConnection()
        {
            //_logger.LogInformation("[TVHclient] HTSConnectionHandler.ensureConnection()");
            if (_htsConnection == null || _htsConnection.needsRestart())
            {
                _logger.LogInformation("[TVHclient] HTSConnectionHandler.ensureConnection() : create new HTS-Connection");
                Version version = Assembly.GetEntryAssembly().GetName().Version;
                _htsConnection = new HTSConnectionAsync(this, "TVHclient4Emby-" + version.ToString(), "" + HTSMessage.HTSP_VERSION, _logger);
                _connected     = false;
            }

            lock (_lock)
            {
                if (!_connected)
                {
                    _logger.LogInformation("[TVHclient] HTSConnectionHandler.ensureConnection: Used connection parameters: " +
                                           "TVH Server = '{servername}'; HTTP Port = '{httpport}'; HTSP Port = '{htspport}'; Web-Root = '{webroot}'; " +
                                           "User = '******'; Password set = '{passexists}'",
                                           _tvhServerName, _httpPort, _htspPort, _webRoot, _userName, (_password.Length > 0));

                    _htsConnection.open(_tvhServerName, _htspPort);
                    _connected = _htsConnection.authenticate(_userName, _password);

                    _logger.LogInformation("[TVHclient] HTSConnectionHandler.ensureConnection: connection established {c}", _connected);
                }
            }
        }
Exemplo n.º 3
0
        private void createHTSConnection()
        {
            _logger.Info("[TVHclient] LiveTvService.createHTSConnection()");
            Version version = Assembly.GetEntryAssembly().GetName().Version;

            _htsConnection = new HTSConnectionAsync(this, "TVHclient", version.ToString(), _logger);
            _connected     = false;
        }
Exemplo n.º 4
0
 public void onError(Exception ex)
 {
     _logger.ErrorException("[TVHclient] HTSConnectionHandler recorded a HTSP error: " + ex.Message, ex);
     _htsConnection.stop();
     _htsConnection = null;
     _connected     = false;
     //_liveTvService.sendDataSourceChanged();
     ensureConnection();
 }
 public void onError(Exception ex)
 {
     _logger.LogError(ex, "[TVHclient] HTSConnectionHandler: HTSP error");
     _htsConnection.stop();
     _htsConnection = null;
     _connected     = false;
     //_liveTvService.sendDataSourceChanged();
     ensureConnection();
 }
Exemplo n.º 6
0
        public async Task EnsureConnection(CancellationToken cancellationToken)
        {
            await ConnectionSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                //_logger.Info("[TVHclient] HTSConnectionHandler.ensureConnection()");
                if (_htsConnection == null || _htsConnection.needsRestart())
                {
                    _connected = false;

                    _logger.Info("[TVHclient] HTSConnectionHandler.ensureConnection() : create new HTS-Connection");
                    Version version    = Assembly.GetEntryAssembly().GetName().Version;
                    var     connection = new HTSConnectionAsync(this, "TVHclient4Emby-" + version.ToString(), "" + HTSMessage.HTSP_VERSION, _logger);

                    _logger.Info("[TVHclient] HTSConnectionHandler.ensureConnection: Used connection parameters: " +
                                 "TVH Server = '" + _httpBaseUrl + "'; " +
                                 "HTSP Port = '" + _htspPort + "'; " +
                                 "User = '******'; " +
                                 "Password set = '" + (_password.Length > 0) + "'");

                    await connection.open(_tvhServerName, _htspPort, cancellationToken).ConfigureAwait(false);

                    await connection.Authenticate(_userName, _password, cancellationToken).ConfigureAwait(false);

                    _htsConnection = connection;
                }
                else if (_connected)
                {
                    return;
                }

                var taskCompletionSource = new TaskCompletionSource <bool>();

                lock (connectionOpenListeners)
                {
                    connectionOpenListeners.Add(taskCompletionSource);
                }

                await taskCompletionSource.Task.ConfigureAwait(false);
            }
            finally
            {
                ConnectionSemaphore.Release();
            }
        }
Exemplo n.º 7
0
 public void onError(Exception ex)
 {
     _logger.ErrorException("[TVHclient] HTSConnectionHandler recorded a HTSP error: " + ex.Message, ex);
     _htsConnection.stop();
     _htsConnection = null;
 }