IConnectionManager.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using MediaBrowser.Model.Connect;
  2. using MediaBrowser.Model.Dto;
  3. using MediaBrowser.Model.Events;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace MediaBrowser.Model.ApiClient
  9. {
  10. public interface IConnectionManager
  11. {
  12. /// <summary>
  13. /// Occurs when [connected].
  14. /// </summary>
  15. event EventHandler<GenericEventArgs<ConnectionResult>> Connected;
  16. /// <summary>
  17. /// Occurs when [local user sign in].
  18. /// </summary>
  19. event EventHandler<GenericEventArgs<UserDto>> LocalUserSignIn;
  20. /// <summary>
  21. /// Occurs when [connect user sign in].
  22. /// </summary>
  23. event EventHandler<GenericEventArgs<ConnectUser>> ConnectUserSignIn;
  24. /// <summary>
  25. /// Occurs when [local user sign out].
  26. /// </summary>
  27. event EventHandler<EventArgs> LocalUserSignOut;
  28. /// <summary>
  29. /// Occurs when [connect user sign out].
  30. /// </summary>
  31. event EventHandler<EventArgs> ConnectUserSignOut;
  32. [Obsolete]
  33. event EventHandler<EventArgs> RemoteLoggedOut;
  34. /// <summary>
  35. /// Gets the connect user.
  36. /// </summary>
  37. /// <value>The connect user.</value>
  38. ConnectUser ConnectUser { get; }
  39. /// <summary>
  40. /// Gets the API client.
  41. /// </summary>
  42. /// <param name="item">The item.</param>
  43. /// <returns>IApiClient.</returns>
  44. IApiClient GetApiClient(IHasServerId item);
  45. /// <summary>
  46. /// Connects the specified cancellation token.
  47. /// </summary>
  48. /// <param name="cancellationToken">The cancellation token.</param>
  49. /// <returns>Task&lt;ConnectionResult&gt;.</returns>
  50. Task<ConnectionResult> Connect(CancellationToken cancellationToken);
  51. /// <summary>
  52. /// Connects the specified server.
  53. /// </summary>
  54. /// <param name="server">The server.</param>
  55. /// <param name="cancellationToken">The cancellation token.</param>
  56. /// <returns>Task&lt;ConnectionResult&gt;.</returns>
  57. Task<ConnectionResult> Connect(ServerInfo server, CancellationToken cancellationToken);
  58. /// <summary>
  59. /// Connects the specified server.
  60. /// </summary>
  61. /// <param name="address">The address.</param>
  62. /// <param name="cancellationToken">The cancellation token.</param>
  63. /// <returns>Task&lt;ConnectionResult&gt;.</returns>
  64. Task<ConnectionResult> Connect(string address, CancellationToken cancellationToken);
  65. /// <summary>
  66. /// Logouts this instance.
  67. /// </summary>
  68. /// <returns>Task&lt;ConnectionResult&gt;.</returns>
  69. Task<ConnectionResult> Logout();
  70. /// <summary>
  71. /// Logins to connect.
  72. /// </summary>
  73. /// <returns>Task.</returns>
  74. Task LoginToConnect(string username, string password);
  75. /// <summary>
  76. /// Gets the active api client instance
  77. /// </summary>
  78. [Obsolete]
  79. IApiClient CurrentApiClient { get; }
  80. /// <summary>
  81. /// Creates the pin.
  82. /// </summary>
  83. /// <returns>Task&lt;PinCreationResult&gt;.</returns>
  84. Task<PinCreationResult> CreatePin();
  85. /// <summary>
  86. /// Gets the pin status.
  87. /// </summary>
  88. /// <param name="pin">The pin.</param>
  89. /// <returns>Task&lt;PinStatusResult&gt;.</returns>
  90. Task<PinStatusResult> GetPinStatus(PinCreationResult pin);
  91. /// <summary>
  92. /// Exchanges the pin.
  93. /// </summary>
  94. /// <param name="pin">The pin.</param>
  95. /// <returns>Task.</returns>
  96. Task ExchangePin(PinCreationResult pin);
  97. /// <summary>
  98. /// Gets the available servers.
  99. /// </summary>
  100. /// <param name="cancellationToken">The cancellation token.</param>
  101. Task<List<ServerInfo>> GetAvailableServers(CancellationToken cancellationToken);
  102. }
  103. }