Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrennan Conroy <brecon@microsoft.com>2019-05-24 05:06:46 +0300
committerBrennan Conroy <brecon@microsoft.com>2019-05-24 05:06:46 +0300
commit20ea7d4e0d79f59da1c9c916e381bb35122296fc (patch)
tree20bdbe74b8d4dc0f3002525c25eda80d204c4721
parenteef19949de4f8a028bf26defee659b24914a07ec (diff)
-rw-r--r--src/SignalR/clients/ts/signalr/src/HttpConnection.ts9
-rw-r--r--src/SignalR/clients/ts/signalr/src/HubConnection.ts9
-rw-r--r--src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs5
-rw-r--r--src/SignalR/common/Http.Connections/src/Internal/HttpConnectionDispatcher.cs81
-rw-r--r--src/SignalR/common/Http.Connections/src/Internal/Transports/WebSocketsTransport.cs4
-rw-r--r--src/SignalR/samples/SignalRSamples/Program.cs1
6 files changed, 71 insertions, 38 deletions
diff --git a/src/SignalR/clients/ts/signalr/src/HttpConnection.ts b/src/SignalR/clients/ts/signalr/src/HttpConnection.ts
index 729d01cc32..5cb91746e0 100644
--- a/src/SignalR/clients/ts/signalr/src/HttpConnection.ts
+++ b/src/SignalR/clients/ts/signalr/src/HttpConnection.ts
@@ -207,10 +207,15 @@ export class HttpConnection implements IConnection {
// Store the original base url and the access token factory since they may change
// as part of negotiating
let url = this.baseUrl;
+ let davidsvar = this.options.skipNegotiation;
+ if (this.connectionId) {
+ url += `?id=${this.connectionId}`;
+ davidsvar = true;
+ }
this.accessTokenFactory = this.options.accessTokenFactory;
try {
- if (this.options.skipNegotiation) {
+ if (davidsvar) {
if (this.options.transport === HttpTransportType.WebSockets) {
// No need to add a connection ID in this case
this.transport = this.constructTransport(HttpTransportType.WebSockets);
@@ -450,7 +455,7 @@ export class HttpConnection implements IConnection {
this.logger.log(LogLevel.Information, "Connection disconnected.");
}
- this.connectionId = undefined;
+ // this.connectionId = undefined;
this.connectionState = ConnectionState.Disconnected;
if (this.onclose && this.connectionStarted) {
diff --git a/src/SignalR/clients/ts/signalr/src/HubConnection.ts b/src/SignalR/clients/ts/signalr/src/HubConnection.ts
index 1247c35797..6425b896f2 100644
--- a/src/SignalR/clients/ts/signalr/src/HubConnection.ts
+++ b/src/SignalR/clients/ts/signalr/src/HubConnection.ts
@@ -157,9 +157,9 @@ export class HubConnection {
}
}
- private async startInternal() {
+ private async startInternal(noHandshake: boolean = false) {
this.stopDuringStartError = undefined;
- this.receivedHandshakeResponse = false;
+ // this.receivedHandshakeResponse = false;
// Set up the promise before any connection is (re)started otherwise it could race with received messages
const handshakePromise = new Promise((resolve, reject) => {
this.handshakeResolver = resolve;
@@ -167,6 +167,9 @@ export class HubConnection {
});
await this.connection.start(this.protocol.transferFormat);
+ if (noHandshake) {
+ return;
+ }
try {
const handshakeRequest: HandshakeRequestMessage = {
@@ -711,7 +714,7 @@ export class HubConnection {
}
try {
- await this.startInternal();
+ await this.startInternal(true);
this.connectionState = HubConnectionState.Connected;
this.logger.log(LogLevel.Information, "HubConnection reconnected successfully.");
diff --git a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs
index 5556f76dd1..f8625ffb86 100644
--- a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs
+++ b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionContext.cs
@@ -326,6 +326,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
public bool TryActivatePersistentConnection(
ConnectionDelegate connectionDelegate,
IHttpTransport transport,
+ Task currentRequestTask,
ILogger dispatcherLogger)
{
lock (_stateLock)
@@ -334,8 +335,10 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
{
Status = HttpConnectionStatus.Active;
+ PreviousPollTask = currentRequestTask;
+
// Call into the end point passing the connection
- ApplicationTask = ExecuteApplication(connectionDelegate);
+ ApplicationTask ??= ExecuteApplication(connectionDelegate);
// Start the transport
TransportTask = transport.ProcessRequestAsync(HttpContext, HttpContext.RequestAborted);
diff --git a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionDispatcher.cs b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionDispatcher.cs
index 20bd0ccb24..14d76e2b7d 100644
--- a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionDispatcher.cs
+++ b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionDispatcher.cs
@@ -147,35 +147,42 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
await DoPersistentConnection(connectionDelegate, sse, context, connection);
}
- else if (context.WebSockets.IsWebSocketRequest)
+ //else if (context.WebSockets.IsWebSocketRequest)
+ //{
+ // // Connection can be established lazily
+ // var connection = await GetOrCreateConnectionAsync(context, options);
+ // if (connection == null)
+ // {
+ // // No such connection, GetOrCreateConnection already set the response status code
+ // return;
+ // }
+
+ // if (!await EnsureConnectionStateAsync(connection, context, HttpTransportType.WebSockets, supportedTransports, logScope, options))
+ // {
+ // // Bad connection state. It's already set the response status code.
+ // return;
+ // }
+
+ // Log.EstablishedConnection(_logger);
+
+ // // Allow the reads to be cancelled
+ // connection.Cancellation = new CancellationTokenSource();
+
+ // var ws = new WebSocketsTransport(options.WebSockets, connection.Application, connection, _loggerFactory);
+
+ // await DoPersistentConnection(connectionDelegate, ws, context, connection);
+ //}
+ else
{
- // Connection can be established lazily
- var connection = await GetOrCreateConnectionAsync(context, options);
- if (connection == null)
- {
- // No such connection, GetOrCreateConnection already set the response status code
- return;
- }
+ // GET /{path} maps to long polling
- if (!await EnsureConnectionStateAsync(connection, context, HttpTransportType.WebSockets, supportedTransports, logScope, options))
+ var transport = HttpTransportType.LongPolling;
+ if (context.WebSockets.IsWebSocketRequest)
{
- // Bad connection state. It's already set the response status code.
- return;
+
+ transport = HttpTransportType.WebSockets;
}
- Log.EstablishedConnection(_logger);
-
- // Allow the reads to be cancelled
- connection.Cancellation = new CancellationTokenSource();
-
- var ws = new WebSocketsTransport(options.WebSockets, connection.Application, connection, _loggerFactory);
-
- await DoPersistentConnection(connectionDelegate, ws, context, connection);
- }
- else
- {
- // GET /{path} maps to long polling
-
// Connection must already exist
var connection = await GetConnectionAsync(context);
if (connection == null)
@@ -184,7 +191,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
return;
}
- if (!await EnsureConnectionStateAsync(connection, context, HttpTransportType.LongPolling, supportedTransports, logScope, options))
+ if (!await EnsureConnectionStateAsync(connection, context, transport, supportedTransports, logScope, options))
{
// Bad connection state. It's already set the response status code.
return;
@@ -212,12 +219,26 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
}
}
- if (!connection.TryActivateLongPollingConnection(
- connectionDelegate, context, options.LongPolling.PollTimeout,
- currentRequestTcs.Task, _loggerFactory, _logger))
+ switch (transport)
{
- return;
+ case HttpTransportType.None:
+ break;
+ case HttpTransportType.WebSockets:
+ var ws = new WebSocketsTransport(options.WebSockets, connection.Application, connection, _loggerFactory);
+ connection.TryActivatePersistentConnection(connectionDelegate, ws, currentRequestTcs.Task, _logger);
+ break;
+ case HttpTransportType.LongPolling:
+ if (!connection.TryActivateLongPollingConnection(
+ connectionDelegate, context, options.LongPolling.PollTimeout,
+ currentRequestTcs.Task, _loggerFactory, _logger))
+ {
+ return;
+ }
+ break;
+ default:
+ break;
}
+
var resultTask = await Task.WhenAny(connection.ApplicationTask, connection.TransportTask);
@@ -276,7 +297,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
HttpContext context,
HttpConnectionContext connection)
{
- if (connection.TryActivatePersistentConnection(connectionDelegate, transport, _logger))
+ //if (connection.TryActivatePersistentConnection(connectionDelegate, transport, _logger))
{
// Wait for any of them to end
await Task.WhenAny(connection.ApplicationTask, connection.TransportTask);
diff --git a/src/SignalR/common/Http.Connections/src/Internal/Transports/WebSocketsTransport.cs b/src/SignalR/common/Http.Connections/src/Internal/Transports/WebSocketsTransport.cs
index 8a14478831..700192863d 100644
--- a/src/SignalR/common/Http.Connections/src/Internal/Transports/WebSocketsTransport.cs
+++ b/src/SignalR/common/Http.Connections/src/Internal/Transports/WebSocketsTransport.cs
@@ -207,7 +207,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
finally
{
// We're done writing
- _application.Output.Complete();
+ //_application.Output.Complete();
}
}
@@ -283,7 +283,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports
await socket.CloseOutputAsync(error != null ? WebSocketCloseStatus.InternalServerError : WebSocketCloseStatus.NormalClosure, "", CancellationToken.None);
}
- _application.Input.Complete();
+ //_application.Input.Complete();
}
}
diff --git a/src/SignalR/samples/SignalRSamples/Program.cs b/src/SignalR/samples/SignalRSamples/Program.cs
index 2f932a18a4..430bb714f9 100644
--- a/src/SignalR/samples/SignalRSamples/Program.cs
+++ b/src/SignalR/samples/SignalRSamples/Program.cs
@@ -25,6 +25,7 @@ namespace SignalRSamples
.ConfigureLogging(factory =>
{
factory.AddConsole();
+ factory.SetMinimumLevel(LogLevel.Trace);
})
.UseKestrel(options =>
{