|
|
|
@ -164,33 +164,19 @@ namespace Jellyfin.Server.SocketSharp
|
|
|
|
|
Endpoint = endpoint
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await ReceiveWebSocketAsync(ctx, socket).ConfigureAwait(false);
|
|
|
|
|
await socket.StartReceive().ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogWarning("Web socket connection not allowed");
|
|
|
|
|
ctx.Response.StatusCode = 401;
|
|
|
|
|
ctx.Response.Close();
|
|
|
|
|
TryClose(ctx, 401);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "AcceptWebSocketAsync error");
|
|
|
|
|
ctx.Response.StatusCode = 500;
|
|
|
|
|
ctx.Response.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task ReceiveWebSocketAsync(HttpListenerContext ctx, SharpWebSocket socket)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await socket.StartReceive().ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
TryClose(ctx, 200);
|
|
|
|
|
TryClose(ctx, 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -201,10 +187,6 @@ namespace Jellyfin.Server.SocketSharp
|
|
|
|
|
ctx.Response.StatusCode = statusCode;
|
|
|
|
|
ctx.Response.Close();
|
|
|
|
|
}
|
|
|
|
|
catch (ObjectDisposedException)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Investigate and properly fix.
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Error closing web socket response");
|
|
|
|
|