update connect

This commit is contained in:
Luke Pulverenti
2014-10-13 16:14:53 -04:00
parent 8a15ee6ab4
commit ab3c26c564
34 changed files with 682 additions and 115 deletions

View File

@@ -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>();
}
}
}

View File

@@ -4,6 +4,7 @@ namespace MediaBrowser.Model.ApiClient
{
Unavailable = 1,
ServerSignIn = 2,
SignedIn = 3
SignedIn = 3,
ServerSelection = 4
}
}

View File

@@ -1350,5 +1350,12 @@ namespace MediaBrowser.Model.ApiClient
/// </summary>
/// <returns>Task&lt;DevicesOptions&gt;.</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);
}
}

View File

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

View File

@@ -53,5 +53,17 @@ namespace MediaBrowser.Model.ApiClient
/// </summary>
/// <returns>Task&lt;ConnectionResult&gt;.</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; }
}
}

View File

@@ -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()
{