private Task ProcessNegotiationRequest(HostContext context)
{
// Total amount of time without a keep alive before the client should attempt to reconnect in seconds.
var keepAliveTimeout = _configurationManager.KeepAliveTimeout();
string connectionId = Guid.NewGuid().ToString("d");
string connectionToken = connectionId + ':' + GetUserIdentity(context);
var payload = new
{
Url = context.Request.LocalPath.Replace("/negotiate", ""),
ConnectionToken = ProtectedData.Protect(connectionToken, Purposes.ConnectionToken),
ConnectionId = connectionId,
KeepAliveTimeout = keepAliveTimeout != null ? keepAliveTimeout.Value.TotalSeconds : (double?)null,
DisconnectTimeout = _configurationManager.DisconnectTimeout.TotalSeconds,
ConnectionTimeout = _configurationManager.ConnectionTimeout.TotalSeconds,
TryWebSockets = _transportManager.SupportsTransport(WebSocketsTransportName) && context.Environment.SupportsWebSockets(),
ProtocolVersion = _protocolResolver.Resolve(context.Request).ToString(),
TransportConnectTimeout = _configurationManager.TransportConnectTimeout.TotalSeconds,
LongPollDelay = _configurationManager.LongPollDelay.TotalSeconds
};
return SendJsonResponse(context, JsonSerializer.Stringify(payload));
}