2013-02-26 16:10:55 +00:00
|
|
|
|
using System;
|
2013-02-27 16:46:48 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-26 16:10:55 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2013-03-07 05:34:00 +00:00
|
|
|
|
namespace MediaBrowser.Common.Net
|
2013-02-26 16:10:55 +00:00
|
|
|
|
{
|
2013-09-20 15:37:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interface IServerManager
|
|
|
|
|
/// </summary>
|
2013-02-26 16:10:55 +00:00
|
|
|
|
public interface IServerManager : IDisposable
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether [supports web socket].
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value><c>true</c> if [supports web socket]; otherwise, <c>false</c>.</value>
|
|
|
|
|
bool SupportsNativeWebSocket { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the web socket port number.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The web socket port number.</value>
|
|
|
|
|
int WebSocketPortNumber { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts this instance.
|
|
|
|
|
/// </summary>
|
2013-09-20 15:37:05 +00:00
|
|
|
|
/// <param name="urlPrefix">The URL prefix.</param>
|
|
|
|
|
/// <param name="enableHttpLogging">if set to <c>true</c> [enable HTTP logging].</param>
|
|
|
|
|
void Start(string urlPrefix, bool enableHttpLogging);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts the web socket server.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void StartWebSocketServer();
|
2013-02-26 16:10:55 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends a message to all clients currently connected via a web socket
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="messageType">Type of the message.</param>
|
|
|
|
|
/// <param name="data">The data.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
void SendWebSocketMessage<T>(string messageType, T data);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends a message to all clients currently connected via a web socket
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="messageType">Type of the message.</param>
|
|
|
|
|
/// <param name="dataFunction">The function that generates the data to send, if there are any connected clients</param>
|
|
|
|
|
void SendWebSocketMessage<T>(string messageType, Func<T> dataFunction);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends a message to all clients currently connected via a web socket
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="messageType">Type of the message.</param>
|
|
|
|
|
/// <param name="dataFunction">The function that generates the data to send, if there are any connected clients</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
/// <exception cref="System.ArgumentNullException">messageType</exception>
|
|
|
|
|
Task SendWebSocketMessageAsync<T>(string messageType, Func<T> dataFunction, CancellationToken cancellationToken);
|
2013-02-27 16:46:48 +00:00
|
|
|
|
|
2013-05-22 03:42:25 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sends the web socket message async.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="messageType">Type of the message.</param>
|
|
|
|
|
/// <param name="dataFunction">The data function.</param>
|
|
|
|
|
/// <param name="connections">The connections.</param>
|
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
Task SendWebSocketMessageAsync<T>(string messageType, Func<T> dataFunction, IEnumerable<IWebSocketConnection> connections, CancellationToken cancellationToken);
|
2013-09-20 15:37:05 +00:00
|
|
|
|
|
2013-02-27 16:46:48 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds the web socket listeners.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="listeners">The listeners.</param>
|
|
|
|
|
void AddWebSocketListeners(IEnumerable<IWebSocketListener> listeners);
|
2013-05-22 03:42:25 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the web socket connections.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The web socket connections.</value>
|
|
|
|
|
IEnumerable<IWebSocketConnection> WebSocketConnections { get; }
|
2013-02-26 16:10:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|