2
0

IServerManager.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. namespace MediaBrowser.Common.Net
  6. {
  7. /// <summary>
  8. /// Interface IServerManager
  9. /// </summary>
  10. public interface IServerManager : IDisposable
  11. {
  12. /// <summary>
  13. /// Gets the web socket port number.
  14. /// </summary>
  15. /// <value>The web socket port number.</value>
  16. int WebSocketPortNumber { get; }
  17. /// <summary>
  18. /// Starts this instance.
  19. /// </summary>
  20. /// <param name="urlPrefixes">The URL prefixes.</param>
  21. void Start(IEnumerable<string> urlPrefixes);
  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. /// <summary>
  48. /// Adds the web socket listeners.
  49. /// </summary>
  50. /// <param name="listeners">The listeners.</param>
  51. void AddWebSocketListeners(IEnumerable<IWebSocketListener> listeners);
  52. /// <summary>
  53. /// Gets the web socket connections.
  54. /// </summary>
  55. /// <value>The web socket connections.</value>
  56. IEnumerable<IWebSocketConnection> WebSocketConnections { get; }
  57. }
  58. }