From cd8db6fa54cbec936346098939db986ae52776bb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 2 Oct 2014 23:48:59 -0400 Subject: add connection manager interface --- MediaBrowser.Model/ApiClient/ConnectionResult.cs | 23 ++++++++ MediaBrowser.Model/ApiClient/IApiClient.cs | 14 ++++- MediaBrowser.Model/ApiClient/IConnectionManager.cs | 62 ++++++++++++++++++++++ MediaBrowser.Model/ApiClient/ServerInfo.cs | 23 ++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 MediaBrowser.Model/ApiClient/ConnectionResult.cs create mode 100644 MediaBrowser.Model/ApiClient/IConnectionManager.cs create mode 100644 MediaBrowser.Model/ApiClient/ServerInfo.cs (limited to 'MediaBrowser.Model/ApiClient') diff --git a/MediaBrowser.Model/ApiClient/ConnectionResult.cs b/MediaBrowser.Model/ApiClient/ConnectionResult.cs new file mode 100644 index 000000000..12f89d930 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/ConnectionResult.cs @@ -0,0 +1,23 @@ + +namespace MediaBrowser.Model.ApiClient +{ + public class ConnectionResult + { + public ConnectionState State { get; set; } + public ServerInfo ServerInfo { get; set; } + public IApiClient ApiClient { get; set; } + } + + public enum ConnectionState + { + Unavailable = 1, + ServerSignIn = 2, + SignedIn = 3 + } + + public enum ConnectionMode + { + Local = 1, + Remote = 2 + } +} diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 8b7681c84..3efdea70d 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Model.ApiClient /// /// Interface IApiClient /// - public interface IApiClient : IDisposable + public interface IApiClient : IServerEvents, IDisposable { /// /// Occurs when [HTTP response received]. @@ -1288,5 +1288,17 @@ namespace MediaBrowser.Model.ApiClient /// options [Obsolete] string GetHlsVideoStreamUrl(VideoStreamOptions options); + + /// + /// Sends the context message asynchronous. + /// + /// Type of the item. + /// The item identifier. + /// Name of the item. + /// The context. + /// The cancellation token. + /// Task. + Task SendContextMessageAsync(string itemType, string itemId, string itemName, string context, + CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/MediaBrowser.Model/ApiClient/IConnectionManager.cs b/MediaBrowser.Model/ApiClient/IConnectionManager.cs new file mode 100644 index 000000000..6a2d5c8cf --- /dev/null +++ b/MediaBrowser.Model/ApiClient/IConnectionManager.cs @@ -0,0 +1,62 @@ +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Events; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Model.ApiClient +{ + public interface IConnectionManager + { + /// + /// Occurs when [connected]. + /// + event EventHandler> Connected; + + /// + /// Gets the API client. + /// + /// The item. + /// MediaBrowser.Model.ApiClient.IApiClient. + IApiClient GetApiClient(BaseItemDto item); + + /// + /// Connects the specified cancellation token. + /// + /// The cancellation token. + /// Task<ConnectionResult>. + Task Connect(CancellationToken cancellationToken); + + /// + /// Connects the specified server. + /// + /// The server. + /// The cancellation token. + /// Task<ConnectionResult>. + Task Connect(ServerInfo server, CancellationToken cancellationToken); + + /// + /// Connects the specified server. + /// + /// The address. + /// The cancellation token. + /// Task<ConnectionResult>. + Task Connect(string address, CancellationToken cancellationToken); + + /// + /// Logouts this instance. + /// + /// Task<ConnectionResult>. + Task Logout(); + + /// + /// Authenticates the specified server. + /// + /// The server. + /// The username. + /// The hash. + /// if set to true [remember login]. + /// Task. + Task Authenticate(ServerInfo server, string username, byte[] hash, bool rememberLogin); + } +} diff --git a/MediaBrowser.Model/ApiClient/ServerInfo.cs b/MediaBrowser.Model/ApiClient/ServerInfo.cs new file mode 100644 index 000000000..966263726 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/ServerInfo.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Model.ApiClient +{ + public class ServerInfo + { + public String Name { get; set; } + public String Id { get; set; } + public String LocalAddress { get; set; } + public String RemoteAddress { get; set; } + public String UserId { get; set; } + public String AccessToken { get; set; } + public List MacAddresses { get; set; } + + public ServerInfo() + { + MacAddresses = new List(); + + LocalAddress = "http://localhost:8096"; + } + } +} -- cgit v1.2.3