More cleanup

This commit is contained in:
Claus Vium 2019-02-26 22:57:59 +01:00
parent 5510e8ebee
commit 848cfc32cc
2 changed files with 2 additions and 12 deletions

View File

@ -803,7 +803,6 @@ namespace Emby.Server.Implementations.HttpServer
private bool _disposed; private bool _disposed;
private readonly object _disposeLock = new object(); private readonly object _disposeLock = new object();
private readonly WebSocketSharpListener _websocketlistener;
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {

View File

@ -17,8 +17,6 @@ using Microsoft.Extensions.Logging;
{ {
public class WebSocketSharpListener : IHttpListener public class WebSocketSharpListener : IHttpListener
{ {
private HttpListener _listener;
private readonly ILogger _logger; private readonly ILogger _logger;
private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource(); private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource();
@ -86,14 +84,14 @@ using Microsoft.Extensions.Logging;
do do
{ {
result = await webSocketContext.ReceiveAsync(buffer, CancellationToken.None); result = await webSocketContext.ReceiveAsync(buffer, _disposeCancellationToken);
socket.OnReceiveBytes(buffer.Array); socket.OnReceiveBytes(buffer.Array);
message.AddRange(buffer.Array.Take(result.Count)); message.AddRange(buffer.Array.Take(result.Count));
} while (!result.EndOfMessage && result.MessageType != WebSocketMessageType.Close); } while (!result.EndOfMessage && result.MessageType != WebSocketMessageType.Close);
socket.OnReceiveBytes(message.ToArray()); socket.OnReceiveBytes(message.ToArray());
await webSocketContext.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure, await webSocketContext.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure,
result.CloseStatusDescription, CancellationToken.None); result.CloseStatusDescription, _disposeCancellationToken);
socket.Dispose(); socket.Dispose();
} }
else else
@ -109,16 +107,9 @@ using Microsoft.Extensions.Logging;
} }
} }
public void Start(IEnumerable<string> urlPrefixes)
{
throw new NotImplementedException();
}
public Task Stop() public Task Stop()
{ {
_disposeCancellationTokenSource.Cancel(); _disposeCancellationTokenSource.Cancel();
_listener?.Close();
return Task.CompletedTask; return Task.CompletedTask;
} }