IServerManager.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using MediaBrowser.Common.Net;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Controller.Net
  7. {
  8. /// <summary>
  9. /// Interface IServerManager
  10. /// </summary>
  11. public interface IServerManager : IDisposable
  12. {
  13. /// <summary>
  14. /// Starts this instance.
  15. /// </summary>
  16. /// <param name="urlPrefixes">The URL prefixes.</param>
  17. /// <param name="certificatePath">If an https prefix is specified,
  18. /// the ssl certificate localtion on the file system.</param>
  19. void Start(IEnumerable<string> urlPrefixes, string certificatePath);
  20. /// <summary>
  21. /// Sends a message to all clients currently connected via a web socket
  22. /// </summary>
  23. /// <typeparam name="T"></typeparam>
  24. /// <param name="messageType">Type of the message.</param>
  25. /// <param name="data">The data.</param>
  26. /// <returns>Task.</returns>
  27. void SendWebSocketMessage<T>(string messageType, T data);
  28. /// <summary>
  29. /// Sends a message to all clients currently connected via a web socket
  30. /// </summary>
  31. /// <typeparam name="T"></typeparam>
  32. /// <param name="messageType">Type of the message.</param>
  33. /// <param name="dataFunction">The function that generates the data to send, if there are any connected clients</param>
  34. void SendWebSocketMessage<T>(string messageType, Func<T> dataFunction);
  35. /// <summary>
  36. /// Sends a message to all clients currently connected via a web socket
  37. /// </summary>
  38. /// <typeparam name="T"></typeparam>
  39. /// <param name="messageType">Type of the message.</param>
  40. /// <param name="dataFunction">The function that generates the data to send, if there are any connected clients</param>
  41. /// <param name="cancellationToken">The cancellation token.</param>
  42. /// <returns>Task.</returns>
  43. /// <exception cref="System.ArgumentNullException">messageType</exception>
  44. Task SendWebSocketMessageAsync<T>(string messageType, Func<T> dataFunction, CancellationToken cancellationToken);
  45. /// <summary>
  46. /// Adds the web socket listeners.
  47. /// </summary>
  48. /// <param name="listeners">The listeners.</param>
  49. void AddWebSocketListeners(IEnumerable<IWebSocketListener> listeners);
  50. /// <summary>
  51. /// Gets the web socket connections.
  52. /// </summary>
  53. /// <value>The web socket connections.</value>
  54. IEnumerable<IWebSocketConnection> WebSocketConnections { get; }
  55. }
  56. }