Beispiel #1
0
        public HttpServer(int port)
        {
            prefixes.TryAdd(
                "/favicon.ico",
                new StaticHandler(
                    new ResourceResponse(HttpCode.Ok, "image/icon", "favicon"))
                );
            prefixes.TryAdd(
                "/static/browse.css",
                new StaticHandler(
                    new ResourceResponse(HttpCode.Ok, "text/css", "browse_css"))
                );
            RegisterHandler(new IconHandler());

            listener            = new TcpListener(new IPEndPoint(IPAddress.Any, port));
            listener.Server.Ttl = 32;
            listener.Server.UseOnlyOverlappedIO = true;
            listener.Start();

            RealPort = ((IPEndPoint)listener.LocalEndpoint).Port;

            NoticeFormat(
                "Running HTTP Server: {0} on port {1}", Signature, RealPort);
            ssdpServer = new SsdpHandler();

            timeouter.Elapsed += TimeouterCallback;
            timeouter.Enabled  = true;

            Accept();
        }
Beispiel #2
0
 public DlnaEntryPoint(IServerConfigurationManager config,
                       ILogManager logManager,
                       IServerApplicationHost appHost,
                       INetworkManager network,
                       ISessionManager sessionManager,
                       IHttpClient httpClient,
                       ILibraryManager libraryManager,
                       IUserManager userManager,
                       IDlnaManager dlnaManager,
                       IImageProcessor imageProcessor,
                       IUserDataManager userDataManager,
                       ILocalizationManager localization,
                       IMediaSourceManager mediaSourceManager,
                       ISsdpHandler ssdpHandler, IDeviceDiscovery deviceDiscovery)
 {
     _config             = config;
     _appHost            = appHost;
     _network            = network;
     _sessionManager     = sessionManager;
     _httpClient         = httpClient;
     _libraryManager     = libraryManager;
     _userManager        = userManager;
     _dlnaManager        = dlnaManager;
     _imageProcessor     = imageProcessor;
     _userDataManager    = userDataManager;
     _localization       = localization;
     _mediaSourceManager = mediaSourceManager;
     _deviceDiscovery    = deviceDiscovery;
     _ssdpHandler        = (SsdpHandler)ssdpHandler;
     _logger             = logManager.GetLogger("Dlna");
 }
Beispiel #3
0
        public HttpServer(ILogger logger, int port)
        {
            Logger = logger;

            prefixes.TryAdd(
                "/favicon.ico",
                new StaticHandler(
                    new ResourceResponse(HttpCode.Ok, "image/icon", "favicon.ico"))
                );
            prefixes.TryAdd(
                "/static/browse.css",
                new StaticHandler(
                    new ResourceResponse(HttpCode.Ok, "text/css", "browse.css"))
                );
            RegisterHandler(new IconHandler());

            listener            = new TcpListener(new IPEndPoint(IPAddress.Any, port));
            listener.Server.Ttl = 32;
            listener.Server.UseOnlyOverlappedIO = true;
            listener.Start();

            RealPort = ((IPEndPoint)listener.LocalEndpoint).Port;

            Logger.LogInformation($"Running DLNA HTTP Server: {Signature} on port {RealPort}");
            ssdpServer = new SsdpHandler(logger);

            timeouter.Elapsed += TimeouterCallback;
            timeouter.Enabled  = true;

            Accept();
        }
Beispiel #4
0
        private void StartSsdpHandler()
        {
            try
            {
                _ssdpHandler = new SsdpHandler(_logger, _config, GenerateServerSignature());

                _ssdpHandler.Start();
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error starting Dlna server", ex);
            }
        }
Beispiel #5
0
 public PlayToController(SessionInfo session, ISessionManager sessionManager, IItemRepository itemRepository, ILibraryManager libraryManager, ILogger logger, IDlnaManager dlnaManager, IUserManager userManager, IDtoService dtoService, IImageProcessor imageProcessor, SsdpHandler ssdpHandler, string serverAddress)
 {
     _session        = session;
     _itemRepository = itemRepository;
     _sessionManager = sessionManager;
     _libraryManager = libraryManager;
     _dlnaManager    = dlnaManager;
     _userManager    = userManager;
     _dtoService     = dtoService;
     _imageProcessor = imageProcessor;
     _ssdpHandler    = ssdpHandler;
     _serverAddress  = serverAddress;
     _logger         = logger;
 }
        private void StartSsdpHandler()
        {
            try
            {
                _ssdpHandler = new SsdpHandler(_logger, _config, GenerateServerSignature());

                _ssdpHandler.Start();

                _deviceDiscovery = new DeviceDiscovery(_logger, _config, _ssdpHandler, _appHost);

                _deviceDiscovery.Start();
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error starting ssdp handlers", ex);
            }
        }
Beispiel #7
0
        public PlayToManager(ILogger logger, IServerConfigurationManager config, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepository, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IDtoService dtoService, IImageProcessor imageProcessor, SsdpHandler ssdpHandler)
        {
            _tokenSource = new CancellationTokenSource();

            _logger         = logger;
            _sessionManager = sessionManager;
            _httpClient     = httpClient;
            _itemRepository = itemRepository;
            _libraryManager = libraryManager;
            _userManager    = userManager;
            _dlnaManager    = dlnaManager;
            _appHost        = appHost;
            _dtoService     = dtoService;
            _imageProcessor = imageProcessor;
            _ssdpHandler    = ssdpHandler;
            _config         = config;
        }