Skip to content

Commit

Permalink
Rename methods to better convey they are overloads of each other
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Jul 18, 2024
1 parent 3def1bd commit 0cc6189
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions osu.Server.Spectator/ConcurrentConnectionLimiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void log(HubLifetimeContext context, string message)

using (var userState = await connectionStates.GetForUse(userId))
{
if (userState.Item?.IsInvocationPermitted(invocationContext) != true)
if (userState.Item?.ExistingConnectionMatches(invocationContext) != true)
throw new InvalidOperationException($"State is not valid for this connection, context: {LoggingHubFilter.GetMethodCallDisplayString(invocationContext)})");
}

Expand All @@ -121,7 +121,7 @@ private async Task unregisterConnection(HubLifetimeContext context, Exception? e

using (var userState = await connectionStates.GetForUse(userId, true))
{
if (userState.Item?.CanCleanUpConnection(context) == true)
if (userState.Item?.ExistingConnectionMatches(context) == true)
{
log(context, "disconnected from hub");
userState.Item!.ConnectionIds.Remove(context.Hub.GetType());
Expand Down
4 changes: 2 additions & 2 deletions osu.Server.Spectator/Entities/ConnectionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public bool IsConnectionFromSameClient(HubLifetimeContext context)
return TokenId == context.Context.GetTokenId();
}

public bool IsInvocationPermitted(HubInvocationContext context)
public bool ExistingConnectionMatches(HubInvocationContext context)
{
bool hubRegistered = ConnectionIds.TryGetValue(context.Hub.GetType(), out string? registeredConnectionId);
bool connectionIdMatches = registeredConnectionId == context.Context.ConnectionId;

return hubRegistered && connectionIdMatches;
}

public bool CanCleanUpConnection(HubLifetimeContext context)
public bool ExistingConnectionMatches(HubLifetimeContext context)
{
bool hubRegistered = ConnectionIds.TryGetValue(context.Hub.GetType(), out string? registeredConnectionId);
bool connectionIdMatches = registeredConnectionId == context.Context.ConnectionId;
Expand Down

0 comments on commit 0cc6189

Please sign in to comment.