|
|
@ -49,6 +49,8 @@ namespace MediaBrowser.Server.Implementations.WebSocket
|
|
|
|
/// <value>The port.</value>
|
|
|
|
/// <value>The port.</value>
|
|
|
|
public int Port { get; private set; }
|
|
|
|
public int Port { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool _hasStarted;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Starts the specified port number.
|
|
|
|
/// Starts the specified port number.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -60,10 +62,12 @@ namespace MediaBrowser.Server.Implementations.WebSocket
|
|
|
|
WebSocketServer = new WebSocketServer(portNumber, IPAddress.Any)
|
|
|
|
WebSocketServer = new WebSocketServer(portNumber, IPAddress.Any)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OnConnected = OnAlchemyWebSocketClientConnected,
|
|
|
|
OnConnected = OnAlchemyWebSocketClientConnected,
|
|
|
|
TimeOut = TimeSpan.FromHours(12)
|
|
|
|
TimeOut = TimeSpan.FromHours(24)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
WebSocketServer.Start();
|
|
|
|
WebSocketServer.Start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_hasStarted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (SocketException ex)
|
|
|
|
catch (SocketException ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -122,8 +126,12 @@ namespace MediaBrowser.Server.Implementations.WebSocket
|
|
|
|
protected virtual void Dispose(bool dispose)
|
|
|
|
protected virtual void Dispose(bool dispose)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (WebSocketServer != null)
|
|
|
|
if (WebSocketServer != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_hasStarted)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WebSocketServer.Stop();
|
|
|
|
WebSocketServer.Stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
WebSocketServer.Dispose();
|
|
|
|
WebSocketServer.Dispose();
|
|
|
|
WebSocketServer = null;
|
|
|
|
WebSocketServer = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|