diff options
Diffstat (limited to 'MediaBrowser.Model/ApiClient')
| -rw-r--r-- | MediaBrowser.Model/ApiClient/ConnectionResult.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/ApiClient/ConnectionState.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Model/ApiClient/IApiClient.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Model/ApiClient/IClientWebSocket.cs | 54 | ||||
| -rw-r--r-- | MediaBrowser.Model/ApiClient/IConnectionManager.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Model/ApiClient/ServerInfo.cs | 1 |
6 files changed, 80 insertions, 3 deletions
diff --git a/MediaBrowser.Model/ApiClient/ConnectionResult.cs b/MediaBrowser.Model/ApiClient/ConnectionResult.cs index 0b6c0bfe9..86c94c3d5 100644 --- a/MediaBrowser.Model/ApiClient/ConnectionResult.cs +++ b/MediaBrowser.Model/ApiClient/ConnectionResult.cs @@ -1,15 +1,17 @@ - +using System.Collections.Generic; + namespace MediaBrowser.Model.ApiClient { public class ConnectionResult { public ConnectionState State { get; set; } - public ServerInfo ServerInfo { get; set; } + public List<ServerInfo> Servers { get; set; } public IApiClient ApiClient { get; set; } public ConnectionResult() { State = ConnectionState.Unavailable; + Servers = new List<ServerInfo>(); } } } diff --git a/MediaBrowser.Model/ApiClient/ConnectionState.cs b/MediaBrowser.Model/ApiClient/ConnectionState.cs index 9374c77f6..63e156eb1 100644 --- a/MediaBrowser.Model/ApiClient/ConnectionState.cs +++ b/MediaBrowser.Model/ApiClient/ConnectionState.cs @@ -4,6 +4,7 @@ namespace MediaBrowser.Model.ApiClient { Unavailable = 1, ServerSignIn = 2, - SignedIn = 3 + SignedIn = 3, + ServerSelection = 4 } }
\ No newline at end of file diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 1d2145b3a..13088945a 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -1350,5 +1350,12 @@ namespace MediaBrowser.Model.ApiClient /// </summary> /// <returns>Task<DevicesOptions>.</returns> Task<DevicesOptions> GetDevicesOptions(); + + /// <summary> + /// Opens the web socket. + /// </summary> + /// <param name="webSocketFactory">The web socket factory.</param> + /// <param name="keepAliveTimerMs">The keep alive timer ms.</param> + void OpenWebSocket(Func<IClientWebSocket> webSocketFactory, int keepAliveTimerMs = 60000); } }
\ No newline at end of file diff --git a/MediaBrowser.Model/ApiClient/IClientWebSocket.cs b/MediaBrowser.Model/ApiClient/IClientWebSocket.cs new file mode 100644 index 000000000..ca3a761d4 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/IClientWebSocket.cs @@ -0,0 +1,54 @@ +using MediaBrowser.Model.Net; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Model.ApiClient +{ + /// <summary> + /// Interface IClientWebSocket + /// </summary> + public interface IClientWebSocket : IDisposable + { + /// <summary> + /// Occurs when [closed]. + /// </summary> + event EventHandler Closed; + + /// <summary> + /// Gets or sets the state. + /// </summary> + /// <value>The state.</value> + WebSocketState State { get; } + + /// <summary> + /// Connects the async. + /// </summary> + /// <param name="url">The URL.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task.</returns> + Task ConnectAsync(string url, CancellationToken cancellationToken); + + /// <summary> + /// Gets or sets the receive action. + /// </summary> + /// <value>The receive action.</value> + Action<byte[]> OnReceiveBytes { get; set; } + + /// <summary> + /// Gets or sets the on receive. + /// </summary> + /// <value>The on receive.</value> + Action<string> OnReceive { get; set; } + + /// <summary> + /// Sends the async. + /// </summary> + /// <param name="bytes">The bytes.</param> + /// <param name="type">The type.</param> + /// <param name="endOfMessage">if set to <c>true</c> [end of message].</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task.</returns> + Task SendAsync(byte[] bytes, WebSocketMessageType type, bool endOfMessage, CancellationToken cancellationToken); + } +} diff --git a/MediaBrowser.Model/ApiClient/IConnectionManager.cs b/MediaBrowser.Model/ApiClient/IConnectionManager.cs index 03d3472d2..d76ef67d2 100644 --- a/MediaBrowser.Model/ApiClient/IConnectionManager.cs +++ b/MediaBrowser.Model/ApiClient/IConnectionManager.cs @@ -53,5 +53,17 @@ namespace MediaBrowser.Model.ApiClient /// </summary> /// <returns>Task<ConnectionResult>.</returns> Task<ConnectionResult> Logout(); + + /// <summary> + /// Logins to connect. + /// </summary> + /// <returns>Task.</returns> + Task LoginToConnect(string username, string password); + + /// <summary> + /// Gets the active api client instance + /// </summary> + [Obsolete] + IApiClient CurrentApiClient { get; } } } diff --git a/MediaBrowser.Model/ApiClient/ServerInfo.cs b/MediaBrowser.Model/ApiClient/ServerInfo.cs index 0656337ba..af46cc660 100644 --- a/MediaBrowser.Model/ApiClient/ServerInfo.cs +++ b/MediaBrowser.Model/ApiClient/ServerInfo.cs @@ -12,6 +12,7 @@ namespace MediaBrowser.Model.ApiClient public String UserId { get; set; } public String AccessToken { get; set; } public List<WakeOnLanInfo> WakeOnLanInfos { get; set; } + public DateTime DateLastAccessed { get; set; } public ServerInfo() { |
