Fix websockets and RawUrl

This commit is contained in:
Claus Vium 2019-02-26 19:48:18 +01:00
parent d6c6f3c10c
commit 5a7cca9d1b
3 changed files with 13 additions and 4 deletions

View File

@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.SocketSharp
_cancellationTokenSource.Cancel();
// TODO
WebSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "bye", CancellationToken.None).GetAwaiter().GetResult();
// WebSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "bye", CancellationToken.None).GetAwaiter().GetResult();
}
_disposed = true;

View File

@ -160,6 +160,15 @@ using Microsoft.Extensions.Logging;
var buffer = WebSocket.CreateClientBuffer(1024 * 4, 1024 * 4);
WebSocketReceiveResult result = await webSocketContext.ReceiveAsync(buffer, CancellationToken.None);
socket.OnReceiveBytes(buffer.Array);
while (result.MessageType != WebSocketMessageType.Close)
{
result = await webSocketContext.ReceiveAsync(buffer, CancellationToken.None);
socket.OnReceiveBytes(buffer.Array);
}
await webSocketContext.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
socket.Dispose();
//while (!result.CloseStatus.HasValue)
//{
// await webSocketContext.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None);
@ -173,11 +182,11 @@ using Microsoft.Extensions.Logging;
// WebSocket = webSocketContext,
// Endpoint = endpoint
//});
await webSocketContext.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
//await webSocketContext.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
//SharpWebSocket socket = new SharpWebSocket(webSocketContext, _logger);
//await socket.ConnectAsServerAsync().ConfigureAwait(false);
//await ReceiveWebSocketAsync(ctx, socket).ConfigureAwait(false);
}

View File

@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.SocketSharp
public object Dto { get; set; }
public string RawUrl => request.Path.ToString();
public string RawUrl => request.GetEncodedPathAndQuery();
public string AbsoluteUri => request.GetDisplayUrl().TrimEnd('/');