add connection manager interface

This commit is contained in:
Luke Pulverenti
2014-10-02 23:48:59 -04:00
parent cf745bb888
commit cd8db6fa54
40 changed files with 240 additions and 23 deletions

View File

@@ -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
}
}

View File

@@ -25,7 +25,7 @@ namespace MediaBrowser.Model.ApiClient
/// <summary>
/// Interface IApiClient
/// </summary>
public interface IApiClient : IDisposable
public interface IApiClient : IServerEvents, IDisposable
{
/// <summary>
/// Occurs when [HTTP response received].
@@ -1288,5 +1288,17 @@ namespace MediaBrowser.Model.ApiClient
/// <exception cref="ArgumentNullException">options</exception>
[Obsolete]
string GetHlsVideoStreamUrl(VideoStreamOptions options);
/// <summary>
/// Sends the context message asynchronous.
/// </summary>
/// <param name="itemType">Type of the item.</param>
/// <param name="itemId">The item identifier.</param>
/// <param name="itemName">Name of the item.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SendContextMessageAsync(string itemType, string itemId, string itemName, string context,
CancellationToken cancellationToken);
}
}

View File

@@ -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
{
/// <summary>
/// Occurs when [connected].
/// </summary>
event EventHandler<GenericEventArgs<ConnectionResult>> Connected;
/// <summary>
/// Gets the API client.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>MediaBrowser.Model.ApiClient.IApiClient.</returns>
IApiClient GetApiClient(BaseItemDto item);
/// <summary>
/// Connects the specified cancellation token.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;ConnectionResult&gt;.</returns>
Task<ConnectionResult> Connect(CancellationToken cancellationToken);
/// <summary>
/// Connects the specified server.
/// </summary>
/// <param name="server">The server.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;ConnectionResult&gt;.</returns>
Task<ConnectionResult> Connect(ServerInfo server, CancellationToken cancellationToken);
/// <summary>
/// Connects the specified server.
/// </summary>
/// <param name="address">The address.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;ConnectionResult&gt;.</returns>
Task<ConnectionResult> Connect(string address, CancellationToken cancellationToken);
/// <summary>
/// Logouts this instance.
/// </summary>
/// <returns>Task&lt;ConnectionResult&gt;.</returns>
Task<ConnectionResult> Logout();
/// <summary>
/// Authenticates the specified server.
/// </summary>
/// <param name="server">The server.</param>
/// <param name="username">The username.</param>
/// <param name="hash">The hash.</param>
/// <param name="rememberLogin">if set to <c>true</c> [remember login].</param>
/// <returns>Task.</returns>
Task Authenticate(ServerInfo server, string username, byte[] hash, bool rememberLogin);
}
}

View File

@@ -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<string> MacAddresses { get; set; }
public ServerInfo()
{
MacAddresses = new List<string>();
LocalAddress = "http://localhost:8096";
}
}
}