Remove GetOrAdd from AddNewConnection

This commit is contained in:
David Fowler 2016-10-01 03:53:00 -07:00
parent f4f763f136
commit 40ecc9df4d
1 changed files with 7 additions and 10 deletions

View File

@ -39,21 +39,18 @@ namespace Microsoft.AspNetCore.Sockets
{
string id = MakeNewConnectionId();
var state = _connections.GetOrAdd(id, connectionId => new ConnectionState());
// If there's no connection object then it's a new connection
if (state.Connection == null)
var state = new ConnectionState
{
state.Connection = new Connection
Connection = new Connection
{
Channel = channel,
ConnectionId = id
};
}
},
LastSeen = DateTimeOffset.UtcNow,
Active = true
};
// Update the last seen and mark the connection as active
state.LastSeen = DateTimeOffset.UtcNow;
state.Active = true;
_connections.TryAdd(id, state);
return state;
}