IServerManager.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. namespace MediaBrowser.Common.Net
  6. {
  7. public interface IServerManager : IDisposable
  8. {
  9. /// <summary>
  10. /// Gets a value indicating whether [supports web socket].
  11. /// </summary>
  12. /// <value><c>true</c> if [supports web socket]; otherwise, <c>false</c>.</value>
  13. bool SupportsNativeWebSocket { get; }
  14. /// <summary>
  15. /// Gets the web socket port number.
  16. /// </summary>
  17. /// <value>The web socket port number.</value>
  18. int WebSocketPortNumber { get; }
  19. /// <summary>
  20. /// Starts this instance.
  21. /// </summary>
  22. void Start();
  23. /// <summary>
  24. /// Sends a message to all clients currently connected via a web socket
  25. /// </summary>
  26. /// <typeparam name="T"></typeparam>
  27. /// <param name="messageType">Type of the message.</param>
  28. /// <param name="data">The data.</param>
  29. /// <returns>Task.</returns>
  30. void SendWebSocketMessage<T>(string messageType, T data);
  31. /// <summary>
  32. /// Sends a message to all clients currently connected via a web socket
  33. /// </summary>
  34. /// <typeparam name="T"></typeparam>
  35. /// <param name="messageType">Type of the message.</param>
  36. /// <param name="dataFunction">The function that generates the data to send, if there are any connected clients</param>
  37. void SendWebSocketMessage<T>(string messageType, Func<T> dataFunction);
  38. /// <summary>
  39. /// Sends a message to all clients currently connected via a web socket
  40. /// </summary>
  41. /// <typeparam name="T"></typeparam>
  42. /// <param name="messageType">Type of the message.</param>
  43. /// <param name="dataFunction">The function that generates the data to send, if there are any connected clients</param>
  44. /// <param name="cancellationToken">The cancellation token.</param>
  45. /// <returns>Task.</returns>
  46. /// <exception cref="System.ArgumentNullException">messageType</exception>
  47. Task SendWebSocketMessageAsync<T>(string messageType, Func<T> dataFunction, CancellationToken cancellationToken);
  48. /// <summary>
  49. /// Adds the web socket listeners.
  50. /// </summary>
  51. /// <param name="listeners">The listeners.</param>
  52. void AddWebSocketListeners(IEnumerable<IWebSocketListener> listeners);
  53. }
  54. }