Remove GetOrAdd from AddNewConnection
This commit is contained in:
parent
f4f763f136
commit
40ecc9df4d
|
|
@ -39,21 +39,18 @@ namespace Microsoft.AspNetCore.Sockets
|
||||||
{
|
{
|
||||||
string id = MakeNewConnectionId();
|
string id = MakeNewConnectionId();
|
||||||
|
|
||||||
var state = _connections.GetOrAdd(id, connectionId => new ConnectionState());
|
var state = new ConnectionState
|
||||||
|
|
||||||
// If there's no connection object then it's a new connection
|
|
||||||
if (state.Connection == null)
|
|
||||||
{
|
{
|
||||||
state.Connection = new Connection
|
Connection = new Connection
|
||||||
{
|
{
|
||||||
Channel = channel,
|
Channel = channel,
|
||||||
ConnectionId = id
|
ConnectionId = id
|
||||||
};
|
},
|
||||||
}
|
LastSeen = DateTimeOffset.UtcNow,
|
||||||
|
Active = true
|
||||||
|
};
|
||||||
|
|
||||||
// Update the last seen and mark the connection as active
|
_connections.TryAdd(id, state);
|
||||||
state.LastSeen = DateTimeOffset.UtcNow;
|
|
||||||
state.Active = true;
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue