aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ApiInteraction/ApiClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ApiInteraction/ApiClient.cs')
-rw-r--r--MediaBrowser.ApiInteraction/ApiClient.cs34
1 files changed, 25 insertions, 9 deletions
diff --git a/MediaBrowser.ApiInteraction/ApiClient.cs b/MediaBrowser.ApiInteraction/ApiClient.cs
index 5685638f6..0750223b6 100644
--- a/MediaBrowser.ApiInteraction/ApiClient.cs
+++ b/MediaBrowser.ApiInteraction/ApiClient.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Net.Http;
using System.Threading.Tasks;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
@@ -10,20 +9,32 @@ using MediaBrowser.Model.Users;
namespace MediaBrowser.ApiInteraction
{
- public class ApiClient : BaseClient
+ public class ApiClient : IDisposable
{
- public IJsonSerializer JsonSerializer { get; set; }
+ /// <summary>
+ /// Gets or sets the server host name (myserver or 192.168.x.x)
+ /// </summary>
+ public string ServerHostName { get; set; }
- public ApiClient()
- : base()
- {
- }
+ /// <summary>
+ /// Gets or sets the port number used by the API
+ /// </summary>
+ public int ServerApiPort { get; set; }
- public ApiClient(HttpClientHandler handler)
- : base(handler)
+ /// <summary>
+ /// Gets the current api url based on hostname and port.
+ /// </summary>
+ protected string ApiUrl
{
+ get
+ {
+ return string.Format("http://{0}:{1}/mediabrowser/api", ServerHostName, ServerApiPort);
+ }
}
+ public IHttpClient HttpClient { get; set; }
+ public IJsonSerializer JsonSerializer { get; set; }
+
/// <summary>
/// Gets an image url that can be used to download an image from the api
/// </summary>
@@ -278,5 +289,10 @@ namespace MediaBrowser.ApiInteraction
return JsonSerializer.DeserializeFromStream<IEnumerable<ApiBaseItemWrapper<ApiBaseItem>>>(stream);
}
}
+
+ public void Dispose()
+ {
+ HttpClient.Dispose();
+ }
}
}