IServerManager.cs 2.2 KB

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