extracted httpclient dependancy

This commit is contained in:
LukePulverenti 2013-02-24 19:13:45 -05:00
parent 5b1eea558a
commit 28ccfb1bd1
40 changed files with 412 additions and 171 deletions

View File

@ -1,4 +1,5 @@
using System;
using MediaBrowser.Common.Kernel;
using System;
using System.Configuration;
using System.IO;
using System.Reflection;
@ -9,7 +10,7 @@ namespace MediaBrowser.Common.Implementations
/// Provides a base class to hold common application paths used by both the Ui and Server.
/// This can be subclassed to add application-specific paths.
/// </summary>
public abstract class BaseApplicationPaths
public abstract class BaseApplicationPaths : IApplicationPaths
{
/// <summary>
/// The _program data path

View File

@ -31,6 +31,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="protobuf-net">
<HintPath>..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll</HintPath>
@ -77,6 +80,9 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -171,12 +171,6 @@ namespace MediaBrowser.Common.Kernel
/// <value>The web socket listeners.</value>
public IEnumerable<IWebSocketListener> WebSocketListeners { get; private set; }
/// <summary>
/// The _HTTP manager
/// </summary>
/// <value>The HTTP manager.</value>
public HttpManager HttpManager { get; private set; }
/// <summary>
/// Gets or sets the TCP manager.
/// </summary>
@ -323,9 +317,6 @@ namespace MediaBrowser.Common.Kernel
Logger.Info("Version {0} initializing", ApplicationVersion);
DisposeHttpManager();
HttpManager = new HttpManager(this, Logger);
await OnConfigurationLoaded().ConfigureAwait(false);
FindParts();
@ -422,7 +413,6 @@ namespace MediaBrowser.Common.Kernel
if (dispose)
{
DisposeTcpManager();
DisposeHttpManager();
}
}
@ -438,18 +428,6 @@ namespace MediaBrowser.Common.Kernel
}
}
/// <summary>
/// Disposes the HTTP manager.
/// </summary>
private void DisposeHttpManager()
{
if (HttpManager != null)
{
HttpManager.Dispose();
HttpManager = null;
}
}
/// <summary>
/// Gets the current application version
/// </summary>

View File

@ -3,7 +3,6 @@ using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;

View File

@ -8,7 +8,6 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Net.WebSockets;
using System.Reflection;
using System.Text;
using System.Threading;
@ -39,7 +38,7 @@ namespace MediaBrowser.Common.Kernel
/// Gets or sets the json serializer.
/// </summary>
/// <value>The json serializer.</value>
private IJsonSerializer _jsonSerializer;
private readonly IJsonSerializer _jsonSerializer;
/// <summary>
/// This subscribes to HttpListener requests and finds the appropriate BaseHandler to process it

View File

@ -72,9 +72,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
@ -102,7 +99,7 @@
<Compile Include="Net\Handlers\BaseActionHandler.cs" />
<Compile Include="Net\Handlers\IHttpServerHandler.cs" />
<Compile Include="Net\Handlers\StaticFileHandler.cs" />
<Compile Include="Net\HttpManager.cs" />
<Compile Include="Net\IHttpClient.cs" />
<Compile Include="Net\IHttpServer.cs" />
<Compile Include="Net\INetworkManager.cs" />
<Compile Include="Net\IRestfulService.cs" />
@ -113,6 +110,8 @@
<Compile Include="Net\UdpMessageReceivedEventArgs.cs" />
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
<Compile Include="Net\WebSocketConnection.cs" />
<Compile Include="Net\WebSocketMessageType.cs" />
<Compile Include="Net\WebSocketState.cs" />
<Compile Include="Plugins\BaseUiPlugin.cs" />
<Compile Include="Plugins\IPlugin.cs" />
<Compile Include="Plugins\IUIPlugin.cs" />

View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Net
{
public interface IHttpClient : IDisposable
{
/// <summary>
/// Performs a GET request and returns the resulting stream
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="resourcePool">The resource pool.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{Stream}.</returns>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
Task<Stream> Get(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
/// <summary>
/// Performs a POST request
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="postData">Params to add to the POST data.</param>
/// <param name="resourcePool">The resource pool.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>stream on success, null on failure</returns>
/// <exception cref="System.ArgumentNullException">postData</exception>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
Task<Stream> Post(string url, Dictionary<string, string> postData, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
/// <summary>
/// Downloads the contents of a given url into a temporary location
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="resourcePool">The resource pool.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param>
/// <param name="userAgent">The user agent.</param>
/// <returns>Task{System.String}.</returns>
/// <exception cref="System.ArgumentNullException">progress</exception>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
Task<string> GetTempFile(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken, IProgress<double> progress, string userAgent = null);
/// <summary>
/// Downloads the contents of a given url into a MemoryStream
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="resourcePool">The resource pool.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{MemoryStream}.</returns>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
Task<MemoryStream> GetMemoryStream(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken);
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
void Dispose();
}
}

View File

@ -1,5 +1,5 @@
using System.Collections.Generic;
using MediaBrowser.Model.Net;
using System.Collections.Generic;
namespace MediaBrowser.Common.Net
{

View File

@ -1,5 +1,4 @@
using System;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;

View File

@ -200,7 +200,7 @@ namespace MediaBrowser.Common.Net
return "image/svg+xml";
}
throw new InvalidOperationException("Argument not supported: " + path);
throw new ArgumentException("Argument not supported: " + path);
}
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Net;
namespace MediaBrowser.Common.Net
{

View File

@ -1,8 +1,7 @@
using System.IO;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using System;
using System.Net.WebSockets;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

View File

@ -0,0 +1,22 @@

namespace MediaBrowser.Common.Net
{
/// <summary>
/// Enum WebSocketMessageType
/// </summary>
public enum WebSocketMessageType
{
/// <summary>
/// The text
/// </summary>
Text,
/// <summary>
/// The binary
/// </summary>
Binary,
/// <summary>
/// The close
/// </summary>
Close,
}
}

View File

@ -0,0 +1,38 @@

namespace MediaBrowser.Common.Net
{
/// <summary>
/// Enum WebSocketState
/// </summary>
public enum WebSocketState
{
/// <summary>
/// The none
/// </summary>
None,
/// <summary>
/// The connecting
/// </summary>
Connecting,
/// <summary>
/// The open
/// </summary>
Open,
/// <summary>
/// The close sent
/// </summary>
CloseSent,
/// <summary>
/// The close received
/// </summary>
CloseReceived,
/// <summary>
/// The closed
/// </summary>
Closed,
/// <summary>
/// The aborted
/// </summary>
Aborted
}
}

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Kernel;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Tasks;
using System;
using System.Linq;

View File

@ -44,7 +44,10 @@ namespace MediaBrowser.Controller.Plugins
/// </summary>
private INetworkManager _networkManager;
private IKernel _kernel;
/// <summary>
/// The _kernel
/// </summary>
private readonly IKernel _kernel;
/// <summary>
/// Initializes a new instance of the <see cref="PluginSecurityManager" /> class.

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Model.Entities;
@ -16,6 +17,22 @@ namespace MediaBrowser.Controller.Providers.Movies
/// </summary>
class FanArtMovieProvider : FanartBaseProvider
{
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
public FanArtMovieProvider(IHttpClient httpClient)
: base()
{
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
}
/// <summary>
/// The fan art base URL
/// </summary>
@ -70,7 +87,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (var xml = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false))
using (var xml = await HttpClient.Get(url, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false))
{
doc.Load(xml);
}
@ -113,7 +130,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
}
cancellationToken.ThrowIfCancellationRequested();
if (Kernel.Instance.Configuration.DownloadMovieArt && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE))
{
var node =
@ -139,7 +156,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
}
cancellationToken.ThrowIfCancellationRequested();
if (Kernel.Instance.Configuration.DownloadMovieDisc && !item.ResolveArgs.ContainsMetaFileByName(DISC_FILE))
{
var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ??
@ -163,7 +180,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
cancellationToken.ThrowIfCancellationRequested();
if (Kernel.Instance.Configuration.DownloadMovieBanner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE))
{
var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ??
@ -187,7 +204,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
cancellationToken.ThrowIfCancellationRequested();
if (Kernel.Instance.Configuration.DownloadMovieThumb && !item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE))
{
var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ??

View File

@ -1,4 +1,6 @@
using MediaBrowser.Common.Extensions;
using System.Net;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Model.Entities;
@ -9,7 +11,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
@ -36,19 +37,31 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <value>The json serializer.</value>
protected IJsonSerializer JsonSerializer { get; private set; }
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="MovieDbProvider" /> class.
/// </summary>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="httpClient">The HTTP client.</param>
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
public MovieDbProvider(IJsonSerializer jsonSerializer)
public MovieDbProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient)
: base()
{
if (jsonSerializer == null)
{
throw new ArgumentNullException("jsonSerializer");
}
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
JsonSerializer = jsonSerializer;
HttpClient = httpClient;
}
/// <summary>
@ -114,7 +127,7 @@ namespace MediaBrowser.Controller.Providers.Movies
{
get
{
LazyInitializer.EnsureInitialized(ref _tmdbSettingsTask, ref _tmdbSettingsTaskInitialized, ref _tmdbSettingsTaskSyncLock, () => GetTmdbSettings(JsonSerializer));
LazyInitializer.EnsureInitialized(ref _tmdbSettingsTask, ref _tmdbSettingsTaskInitialized, ref _tmdbSettingsTaskSyncLock, () => GetTmdbSettings(JsonSerializer, HttpClient));
return _tmdbSettingsTask;
}
}
@ -123,11 +136,11 @@ namespace MediaBrowser.Controller.Providers.Movies
/// Gets the TMDB settings.
/// </summary>
/// <returns>Task{TmdbSettingsResult}.</returns>
private static async Task<TmdbSettingsResult> GetTmdbSettings(IJsonSerializer jsonSerializer)
private static async Task<TmdbSettingsResult> GetTmdbSettings(IJsonSerializer jsonSerializer, IHttpClient httpClient)
{
try
{
using (var json = await Kernel.Instance.HttpManager.Get(String.Format(TmdbConfigUrl, ApiKey), Kernel.Instance.ResourcePools.MovieDb, CancellationToken.None).ConfigureAwait(false))
using (var json = await httpClient.Get(String.Format(TmdbConfigUrl, ApiKey), Kernel.Instance.ResourcePools.MovieDb, CancellationToken.None).ConfigureAwait(false))
{
return jsonSerializer.DeserializeFromStream<TmdbSettingsResult>(json);
}
@ -189,7 +202,7 @@ namespace MediaBrowser.Controller.Providers.Movies
{
//in addition to ours, we need to set the last refreshed time for the local data provider
//so it won't see the new files we download and process them all over again
if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(JsonSerializer);
if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(HttpClient, JsonSerializer);
var data = item.ProviderData.GetValueOrDefault(JsonProvider.Id, new BaseProviderInfo { ProviderId = JsonProvider.Id });
data.LastRefreshed = value;
item.ProviderData[JsonProvider.Id] = data;
@ -460,7 +473,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
}
@ -492,7 +505,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
}
@ -531,7 +544,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url3, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
var response = JsonSerializer.DeserializeFromStream<TmdbAltTitleResults>(json);
@ -611,7 +624,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
var movieResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
@ -710,7 +723,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (var json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (var json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
}
@ -742,7 +755,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
}
@ -777,7 +790,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
cast = JsonSerializer.DeserializeFromStream<TmdbCastResult>(json);
}
@ -803,7 +816,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
releases = JsonSerializer.DeserializeFromStream<TmdbReleasesResult>(json);
}
@ -831,7 +844,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
images = JsonSerializer.DeserializeFromStream<TmdbImages>(json);
}

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Serialization;
using System;
using System.IO;
@ -12,7 +13,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// </summary>
public class MovieProviderFromJson : MovieDbProvider
{
public MovieProviderFromJson(IJsonSerializer jsonSerializer) : base(jsonSerializer)
public MovieProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer) : base(jsonSerializer, httpClient)
{
}

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Serialization;
using System;
using System.IO;
@ -12,7 +13,8 @@ namespace MediaBrowser.Controller.Providers.Movies
/// </summary>
class PersonProviderFromJson : TmdbPersonProvider
{
public PersonProviderFromJson(IJsonSerializer jsonSerializer) : base(jsonSerializer)
public PersonProviderFromJson(IHttpClient httpClient, IJsonSerializer jsonSerializer)
: base(httpClient, jsonSerializer)
{
}

View File

@ -1,6 +1,8 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
@ -9,7 +11,6 @@ using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Controller.Providers.Movies
{
@ -29,18 +30,30 @@ namespace MediaBrowser.Controller.Providers.Movies
/// <value>The json serializer.</value>
protected IJsonSerializer JsonSerializer { get; private set; }
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="MovieDbProvider" /> class.
/// </summary>
/// <param name="httpClient">The HTTP client.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
public TmdbPersonProvider(IJsonSerializer jsonSerializer)
public TmdbPersonProvider(IHttpClient httpClient, IJsonSerializer jsonSerializer)
: base()
{
if (jsonSerializer == null)
{
throw new ArgumentNullException("jsonSerializer");
}
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
JsonSerializer = jsonSerializer;
}
@ -151,7 +164,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
searchResult = JsonSerializer.DeserializeFromStream<PersonSearchResults>(json);
}
@ -177,7 +190,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
if (json != null)
{
@ -240,7 +253,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try
{
using (Stream json = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (Stream json = await HttpClient.Get(url, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
if (json != null)
{
@ -308,7 +321,7 @@ namespace MediaBrowser.Controller.Providers.Movies
var localPath = Path.Combine(item.MetaLocation, targetName);
if (!item.ResolveArgs.ContainsMetaFileByName(targetName))
{
using (var sourceStream = await Kernel.Instance.HttpManager.FetchToMemoryStream(source, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
using (var sourceStream = await HttpClient.GetMemoryStream(source, Kernel.Instance.ResourcePools.MovieDb, cancellationToken).ConfigureAwait(false))
{
await Kernel.Instance.FileSystemManager.SaveToLibraryFilesystem(item, localPath, sourceStream, cancellationToken).ConfigureAwait(false);

View File

@ -1,6 +1,6 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Logging;
using System;
@ -33,16 +33,23 @@ namespace MediaBrowser.Controller.Providers
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// The _HTTP client
/// </summary>
private readonly IHttpClient _httpClient;
/// <summary>
/// Initializes a new instance of the <see cref="ProviderManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="httpClient">The HTTP client.</param>
/// <param name="logger">The logger.</param>
public ProviderManager(Kernel kernel, ILogger logger)
public ProviderManager(Kernel kernel, IHttpClient httpClient, ILogger logger)
: base(kernel)
{
_logger = logger;
_httpClient = httpClient;
_remoteImageCache = new FileSystemRepository(ImagesDataPath);
}
@ -287,7 +294,7 @@ namespace MediaBrowser.Controller.Providers
Path.Combine(item.MetaLocation, targetName) :
_remoteImageCache.GetResourcePath(item.GetType().FullName + item.Path.ToLower(), targetName);
var img = await Kernel.HttpManager.FetchToMemoryStream(source, resourcePool, cancellationToken).ConfigureAwait(false);
var img = await _httpClient.GetMemoryStream(source, resourcePool, cancellationToken).ConfigureAwait(false);
if (Kernel.Configuration.SaveLocalMeta) // queue to media directories
{

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Entities;
@ -15,6 +16,22 @@ namespace MediaBrowser.Controller.Providers.TV
{
protected string FanArtBaseUrl = "http://api.fanart.tv/webservice/series/{0}/{1}/xml/all/1/1";
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
public FanArtTVProvider(IHttpClient httpClient)
: base()
{
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
}
public override bool Supports(BaseItem item)
{
return item is Series;
@ -36,7 +53,7 @@ namespace MediaBrowser.Controller.Providers.TV
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var series = (Series)item;
if (ShouldFetch(series, series.ProviderData.GetValueOrDefault(Id, new BaseProviderInfo { ProviderId = Id })))
{
@ -46,7 +63,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var xml = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false))
using (var xml = await HttpClient.Get(url, Kernel.Instance.ResourcePools.FanArt, cancellationToken).ConfigureAwait(false))
{
doc.Load(xml);
}
@ -56,7 +73,7 @@ namespace MediaBrowser.Controller.Providers.TV
}
cancellationToken.ThrowIfCancellationRequested();
if (doc.HasChildNodes)
{
string path;
@ -83,7 +100,7 @@ namespace MediaBrowser.Controller.Providers.TV
}
cancellationToken.ThrowIfCancellationRequested();
if (Kernel.Instance.Configuration.DownloadTVArt && !series.ResolveArgs.ContainsMetaFileByName(ART_FILE))
{
var node = doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ??
@ -107,7 +124,7 @@ namespace MediaBrowser.Controller.Providers.TV
}
cancellationToken.ThrowIfCancellationRequested();
if (Kernel.Instance.Configuration.DownloadTVThumb && !series.ResolveArgs.ContainsMetaFileByName(THUMB_FILE))
{
var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ??

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Extensions;
using MediaBrowser.Controller.Resolvers.TV;
@ -19,6 +20,21 @@ namespace MediaBrowser.Controller.Providers.TV
/// </summary>
class RemoteEpisodeProvider : BaseMetadataProvider
{
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
public RemoteEpisodeProvider(IHttpClient httpClient)
: base()
{
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
}
/// <summary>
/// The episode query
@ -171,7 +187,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var result = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
using (var result = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
{
doc.Load(result);
}
@ -189,7 +205,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var result = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
using (var result = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
{
if (result != null) doc.Load(result);
usingAbsoluteData = true;

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Resolvers.TV;
using MediaBrowser.Model.Entities;
@ -17,6 +18,21 @@ namespace MediaBrowser.Controller.Providers.TV
/// </summary>
class RemoteSeasonProvider : BaseMetadataProvider
{
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
public RemoteSeasonProvider(IHttpClient httpClient)
: base()
{
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
}
/// <summary>
/// Supportses the specified item.
@ -82,7 +98,7 @@ namespace MediaBrowser.Controller.Providers.TV
protected override async Task<bool> FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var season = (Season)item;
if (!HasLocalMeta(item))
@ -135,7 +151,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var imgs = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
using (var imgs = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
{
images.Load(imgs);
}

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Extensions;
@ -21,6 +22,21 @@ namespace MediaBrowser.Controller.Providers.TV
/// </summary>
class RemoteSeriesProvider : BaseMetadataProvider
{
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
public RemoteSeriesProvider(IHttpClient httpClient)
: base()
{
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
HttpClient = httpClient;
}
/// <summary>
/// The root URL
@ -153,7 +169,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var xml = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
using (var xml = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
{
doc.Load(xml);
}
@ -232,7 +248,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var actors = await Kernel.Instance.HttpManager.Get(urlActors, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
using (var actors = await HttpClient.Get(urlActors, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
{
docActors.Load(actors);
}
@ -299,7 +315,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var imgs = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
using (var imgs = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
{
images.Load(imgs);
}
@ -446,7 +462,7 @@ namespace MediaBrowser.Controller.Providers.TV
try
{
using (var results = await Kernel.Instance.HttpManager.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
using (var results = await HttpClient.Get(url, Kernel.Instance.ResourcePools.TvDb, cancellationToken).ConfigureAwait(false))
{
doc.Load(results);
}

View File

@ -113,16 +113,23 @@ namespace MediaBrowser.Controller.Updates
/// <value>The json serializer.</value>
protected IJsonSerializer JsonSerializer { get; private set; }
/// <summary>
/// Gets the HTTP client.
/// </summary>
/// <value>The HTTP client.</value>
protected IHttpClient HttpClient { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="InstallationManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="httpClient">The HTTP client.</param>
/// <param name="zipClient">The zip client.</param>
/// <param name="networkManager">The network manager.</param>
/// <param name="jsonSerializer"></param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">zipClient</exception>
public InstallationManager(Kernel kernel, IZipClient zipClient, INetworkManager networkManager, IJsonSerializer jsonSerializer, ILogger logger)
public InstallationManager(Kernel kernel, IHttpClient httpClient, IZipClient zipClient, INetworkManager networkManager, IJsonSerializer jsonSerializer, ILogger logger)
: base(kernel)
{
if (zipClient == null)
@ -141,9 +148,13 @@ namespace MediaBrowser.Controller.Updates
{
throw new ArgumentNullException("jsonSerializer");
}
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
JsonSerializer = jsonSerializer;
HttpClient = httpClient;
_networkManager = networkManager;
_logger = logger;
ZipClient = zipClient;
@ -162,7 +173,7 @@ namespace MediaBrowser.Controller.Updates
{
var data = new Dictionary<string, string> { { "key", Kernel.PluginSecurityManager.SupporterKey }, { "mac", _networkManager.GetMacAddress() } };
using (var json = await Kernel.HttpManager.Post(Controller.Kernel.MBAdminUrl + "service/package/retrieveall", data, Kernel.ResourcePools.Mb, cancellationToken).ConfigureAwait(false))
using (var json = await HttpClient.Post(Controller.Kernel.MBAdminUrl + "service/package/retrieveall", data, Kernel.ResourcePools.Mb, cancellationToken).ConfigureAwait(false))
{
cancellationToken.ThrowIfCancellationRequested();
@ -276,7 +287,7 @@ namespace MediaBrowser.Controller.Updates
/// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
public async Task<IEnumerable<PackageVersionInfo>> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken)
{
var catalog = await Kernel.InstallationManager.GetAvailablePackages(cancellationToken).ConfigureAwait(false);
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
var plugins = Kernel.Plugins;
@ -288,7 +299,7 @@ namespace MediaBrowser.Controller.Updates
// Figure out what needs to be installed
return plugins.Select(p =>
{
var latestPluginInfo = Kernel.InstallationManager.GetLatestCompatibleVersion(catalog, p.Name, p.Configuration.UpdateClass);
var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Configuration.UpdateClass);
return latestPluginInfo != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null;
@ -414,7 +425,7 @@ namespace MediaBrowser.Controller.Updates
var target = isArchive ? Kernel.ApplicationPaths.ProgramDataPath : Path.Combine(Kernel.ApplicationPaths.PluginsPath, package.targetFilename);
// Download to temporary file so that, if interrupted, it won't destroy the existing installation
var tempFile = await Kernel.HttpManager.FetchToTempFile(package.sourceUrl, Kernel.ResourcePools.Mb, cancellationToken, progress).ConfigureAwait(false);
var tempFile = await HttpClient.GetTempFile(package.sourceUrl, Kernel.ResourcePools.Mb, cancellationToken, progress).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested();

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
@ -14,12 +15,12 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Net
namespace MediaBrowser.Networking.HttpManager
{
/// <summary>
/// Class HttpManager
/// </summary>
public class HttpManager : IDisposable
public class HttpManager : IHttpClient
{
/// <summary>
/// The _logger
@ -27,20 +28,20 @@ namespace MediaBrowser.Common.Net
private readonly ILogger _logger;
/// <summary>
/// The _kernel
/// The _app paths
/// </summary>
private readonly IKernel _kernel;
private readonly IApplicationPaths _appPaths;
/// <summary>
/// Initializes a new instance of the <see cref="HttpManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="appPaths">The kernel.</param>
/// <param name="logger">The logger.</param>
public HttpManager(IKernel kernel, ILogger logger)
public HttpManager(IApplicationPaths appPaths, ILogger logger)
{
if (kernel == null)
if (appPaths == null)
{
throw new ArgumentNullException("kernel");
throw new ArgumentNullException("appPaths");
}
if (logger == null)
{
@ -48,7 +49,7 @@ namespace MediaBrowser.Common.Net
}
_logger = logger;
_kernel = kernel;
_appPaths = appPaths;
}
/// <summary>
@ -199,7 +200,7 @@ namespace MediaBrowser.Common.Net
/// <returns>Task{System.String}.</returns>
/// <exception cref="System.ArgumentNullException">progress</exception>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
public async Task<string> FetchToTempFile(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken, IProgress<double> progress, string userAgent = null)
public async Task<string> GetTempFile(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken, IProgress<double> progress, string userAgent = null)
{
ValidateParams(url, resourcePool, cancellationToken);
@ -210,7 +211,7 @@ namespace MediaBrowser.Common.Net
cancellationToken.ThrowIfCancellationRequested();
var tempFile = Path.Combine(_kernel.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".tmp");
var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".tmp");
var message = new HttpRequestMessage(HttpMethod.Get, url);
@ -221,7 +222,7 @@ namespace MediaBrowser.Common.Net
await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
_logger.Info("HttpManager.FetchToTempFile url: {0}, temp file: {1}", url, tempFile);
_logger.Info("HttpManager.GetTempFile url: {0}, temp file: {1}", url, tempFile);
try
{
@ -315,7 +316,7 @@ namespace MediaBrowser.Common.Net
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{MemoryStream}.</returns>
/// <exception cref="MediaBrowser.Model.Net.HttpException"></exception>
public async Task<MemoryStream> FetchToMemoryStream(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
public async Task<MemoryStream> GetMemoryStream(string url, SemaphoreSlim resourcePool, CancellationToken cancellationToken)
{
ValidateParams(url, resourcePool, cancellationToken);
@ -327,7 +328,7 @@ namespace MediaBrowser.Common.Net
var ms = new MemoryStream();
_logger.Info("HttpManager.FetchToMemoryStream url: {0}", url);
_logger.Info("HttpManager.GetMemoryStream url: {0}", url);
try
{

View File

@ -25,7 +25,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace MediaBrowser.Networking.Web
namespace MediaBrowser.Networking.HttpServer
{
/// <summary>
/// Class HttpServer

View File

@ -1,10 +1,13 @@
using MediaBrowser.Model.Logging;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System;
using System.Net.WebSockets;
using System.Threading;
using System.Threading.Tasks;
using WebSocketMessageType = MediaBrowser.Common.Net.WebSocketMessageType;
using WebSocketState = MediaBrowser.Common.Net.WebSocketState;
namespace MediaBrowser.Common.Net
namespace MediaBrowser.Networking.HttpServer
{
/// <summary>
/// Class NativeWebSocket
@ -20,7 +23,7 @@ namespace MediaBrowser.Common.Net
/// Gets or sets the web socket.
/// </summary>
/// <value>The web socket.</value>
private WebSocket WebSocket { get; set; }
private System.Net.WebSockets.WebSocket WebSocket { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="NativeWebSocket" /> class.
@ -28,7 +31,7 @@ namespace MediaBrowser.Common.Net
/// <param name="socket">The socket.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">socket</exception>
public NativeWebSocket(WebSocket socket, ILogger logger)
public NativeWebSocket(System.Net.WebSockets.WebSocket socket, ILogger logger)
{
if (socket == null)
{
@ -52,7 +55,17 @@ namespace MediaBrowser.Common.Net
/// <value>The state.</value>
public WebSocketState State
{
get { return WebSocket.State; }
get
{
WebSocketState commonState;
if (!Enum.TryParse(WebSocket.State.ToString(), true, out commonState))
{
_logger.Warn("Unrecognized WebSocketState: {0}", WebSocket.State.ToString());
}
return commonState;
}
}
/// <summary>
@ -113,7 +126,14 @@ namespace MediaBrowser.Common.Net
/// <returns>Task.</returns>
public Task SendAsync(byte[] bytes, WebSocketMessageType type, bool endOfMessage, CancellationToken cancellationToken)
{
return WebSocket.SendAsync(new ArraySegment<byte>(bytes), type, true, cancellationToken);
System.Net.WebSockets.WebSocketMessageType nativeType;
if (!Enum.TryParse(type.ToString(), true, out nativeType))
{
_logger.Warn("Unrecognized WebSocketMessageType: {0}", type.ToString());
}
return WebSocket.SendAsync(new ArraySegment<byte>(bytes), nativeType, true, cancellationToken);
}
/// <summary>

View File

@ -3,7 +3,7 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Networking.Web
namespace MediaBrowser.Networking.HttpServer
{
/// <summary>
/// Class ServerFactory

View File

@ -81,6 +81,9 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Reactive.Core, Version=2.0.20823.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Rx-Core.2.0.21114\lib\Net45\System.Reactive.Core.dll</HintPath>
@ -104,16 +107,17 @@
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
</Compile>
<Compile Include="HttpManager\HttpManager.cs" />
<Compile Include="Udp\UdpServer.cs" />
<Compile Include="WebSocket\AlchemyServer.cs" />
<Compile Include="WebSocket\AlchemyWebSocket.cs" />
<Compile Include="Web\HttpServer.cs" />
<Compile Include="HttpServer\HttpServer.cs" />
<Compile Include="Management\NativeMethods.cs" />
<Compile Include="Management\NetworkManager.cs" />
<Compile Include="Management\NetworkShares.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Web\ServerFactory.cs" />
<Compile Include="Web\NativeWebSocket.cs" />
<Compile Include="HttpServer\ServerFactory.cs" />
<Compile Include="HttpServer\NativeWebSocket.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
@ -145,6 +149,7 @@
<Content Include="swagger-ui\swagger-ui.js" />
<Content Include="swagger-ui\swagger-ui.min.js" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i</PostBuildEvent>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Weather;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
@ -28,25 +29,34 @@ namespace MediaBrowser.Server.Implementations.WorldWeatherOnline
/// <value>The json serializer.</value>
protected IJsonSerializer JsonSerializer { get; private set; }
/// <summary>
/// The _HTTP client
/// </summary>
private IHttpClient HttpClient { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="WeatherProvider" /> class.
/// </summary>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logger">The logger.</param>
/// <exception cref="System.ArgumentNullException">logger</exception>
public WeatherProvider(IJsonSerializer jsonSerializer, ILogger logger)
public WeatherProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, ILogger logger)
{
if (logger == null)
{
throw new ArgumentNullException("logger");
}
if (httpClient == null)
{
throw new ArgumentNullException("httpClient");
}
if (jsonSerializer == null)
{
throw new ArgumentNullException("jsonSerializer");
}
JsonSerializer = jsonSerializer;
HttpClient = httpClient;
Logger = logger;
}
@ -81,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.WorldWeatherOnline
Logger.Info("Accessing weather from " + url);
using (var stream = await Kernel.Instance.HttpManager.Get(url, _weatherSemaphore, cancellationToken).ConfigureAwait(false))
using (var stream = await HttpClient.Get(url, _weatherSemaphore, cancellationToken).ConfigureAwait(false))
{
var data = JsonSerializer.DeserializeFromStream<WeatherResult>(stream).data;

View File

@ -15,9 +15,10 @@ using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Updates;
using MediaBrowser.Networking.HttpManager;
using MediaBrowser.Networking.HttpServer;
using MediaBrowser.Networking.Management;
using MediaBrowser.Networking.Udp;
using MediaBrowser.Networking.Web;
using MediaBrowser.Networking.WebSocket;
using MediaBrowser.Server.Implementations;
using MediaBrowser.ServerApplication.Implementations;
@ -44,12 +45,6 @@ namespace MediaBrowser.ServerApplication
/// <value>The logger.</value>
private ILogger Logger { get; set; }
/// <summary>
/// Gets or sets the iso manager.
/// </summary>
/// <value>The iso manager.</value>
private IIsoManager IsoManager { get; set; }
/// <summary>
/// Gets or sets the log file path.
/// </summary>
@ -143,14 +138,12 @@ namespace MediaBrowser.ServerApplication
RegisterSingleInstance<IApplicationHost>(this);
RegisterSingleInstance(Logger);
IsoManager = new PismoIsoManager(Logger);
RegisterSingleInstance(_applicationPaths);
RegisterSingleInstance<IApplicationPaths>(_applicationPaths);
RegisterSingleInstance(IsoManager);
RegisterSingleInstance(_taskManager);
RegisterSingleInstance<IIsoManager>(() => new PismoIsoManager(Logger));
RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
RegisterSingleInstance<IHttpClient>(() => new HttpManager(_applicationPaths, Logger));
RegisterSingleInstance<INetworkManager>(() => new NetworkManager());
RegisterSingleInstance<IZipClient>(() => new DotNetZipClient());
RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
@ -477,8 +470,6 @@ namespace MediaBrowser.ServerApplication
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
IsoManager.Dispose();
foreach (var part in _disposableParts)
{
part.Dispose();
@ -487,12 +478,4 @@ namespace MediaBrowser.ServerApplication
_disposableParts.Clear();
}
}
public class MyClass
{
public MyClass()
{
}
}
}

View File

@ -367,15 +367,6 @@
<Content Include="CorePlugins\MediaBrowser.Api.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="CorePlugins\MediaBrowser.ApiInteraction.Javascript.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="CorePlugins\MediaBrowser.Server.Sqlite.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="CorePlugins\MediaBrowser.Server.WorldWeatherOnline.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="CorePlugins\MediaBrowser.WebDashboard.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>MediaBrowser.ApiClient</id>
<version>3.0.0.2-beta</version>
<version>3.0.0.4-beta</version>
<title>MediaBrowser.ApiClient</title>
<authors>Media Browser Team</authors>
<owners>scottisafool,Luke</owners>
@ -12,13 +12,13 @@
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="ServiceStack.Text" version="3.9.37" />
<dependency id="protobuf-net" version="2.0.0.621" />
<dependency id="protobuf-net" version="2.0.0.621" />
</group>
<group targetFramework=".NETPortable0.0-net45+sl4+wp71+win8">
<dependency id="Newtonsoft.Json" version="4.5.11" />
<dependency id="Microsoft.Bcl.Async" version="1.0.14-rc" />
<dependency id="Microsoft.Net.Http" version="2.1.3-beta" />
<dependency id="protobuf-net" version="2.0.0.621" />
<dependency id="protobuf-net" version="2.0.0.621" />
</group>
</dependencies>
</metadata>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.1</version>
<version>3.0.4</version>
<title />
<authors>Luke</authors>
<owners>Media Browser Team</owners>
@ -15,10 +15,11 @@
</dependencies>
</metadata>
<files>
<file src="lib\net45\MediaBrowser.ClickOnce.dll" target="lib\net45\MediaBrowser.ClickOnce.dll" />
<file src="lib\net45\MediaBrowser.IsoMounter.dll" target="lib\net45\MediaBrowser.IsoMounter.dll" />
<file src="lib\net45\MediaBrowser.Logging.NLog.dll" target="lib\net45\MediaBrowser.Logging.NLog.dll" />
<file src="lib\net45\MediaBrowser.Networking.dll" target="lib\net45\MediaBrowser.Networking.dll" />
<file src="lib\net45\pfmclrapi.dll" target="lib\net45\pfmclrapi.dll" />
<file src="dlls\MediaBrowser.ClickOnce.dll" target="lib\net45\MediaBrowser.ClickOnce.dll" />
<file src="dlls\MediaBrowser.Common.Implementations.dll" target="lib\net45\MediaBrowser.Common.Implementations.dll" />
<file src="dlls\MediaBrowser.IsoMounter.dll" target="lib\net45\MediaBrowser.IsoMounter.dll" />
<file src="dlls\MediaBrowser.Logging.NLog.dll" target="lib\net45\MediaBrowser.Logging.NLog.dll" />
<file src="dlls\MediaBrowser.Networking.dll" target="lib\net45\MediaBrowser.Networking.dll" />
<file src="dlls\pfmclrapi.dll" target="lib\net45\pfmclrapi.dll" />
</files>
</package>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>1.0.1</version>
<version>3.0.4</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>1.0.0</version>
<version>3.0.4</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners />
@ -10,7 +10,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Contains core components required to build plugins for Media Browser Server.</description>
<dependencies>
<dependency id="MediaBrowser.Common" version="1.0.1" />
<dependency id="MediaBrowser.Common" version="3.0.2" />
</dependencies>
</metadata>
<files>