mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 01:24:44 +01:00
add connection manager interface
This commit is contained in:
23
MediaBrowser.Model/ApiClient/ConnectionResult.cs
Normal file
23
MediaBrowser.Model/ApiClient/ConnectionResult.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
62
MediaBrowser.Model/ApiClient/IConnectionManager.cs
Normal file
62
MediaBrowser.Model/ApiClient/IConnectionManager.cs
Normal 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<ConnectionResult>.</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<ConnectionResult>.</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<ConnectionResult>.</returns>
|
||||
Task<ConnectionResult> Connect(string address, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Logouts this instance.
|
||||
/// </summary>
|
||||
/// <returns>Task<ConnectionResult>.</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);
|
||||
}
|
||||
}
|
||||
23
MediaBrowser.Model/ApiClient/ServerInfo.cs
Normal file
23
MediaBrowser.Model/ApiClient/ServerInfo.cs
Normal 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user