diff --git a/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazor.Middleware.csproj b/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazor.Middleware.csproj
index ca75beda..70a3fc23 100644
--- a/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazor.Middleware.csproj
+++ b/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazor.Middleware.csproj
@@ -1,7 +1,7 @@
- 11.0.0-rc.3.2
+ 11.0.0-rc.3.3
@@ -9,7 +9,7 @@
-
+
diff --git a/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazorHub.cs b/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazorHub.cs
index cdfefda0..d5fd2dc4 100644
--- a/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazorHub.cs
+++ b/src/middleware/BootstrapBlazor.Middleware/BootstrapBlazorHub.cs
@@ -48,8 +48,8 @@ public Task Heartbeat(ClientInfo client)
=> ConnectionHandler.ReportHeartbeatAsync(Context, client, services);
///
- /// 查询在线连接快照,仅返回给调用方,不向消息订阅者广播;查询被禁用或调用方未获授权时返回 null
- /// Queries a connection snapshot for the caller only, without broadcasting it to dispatch subscribers. Returns null when queries are disabled or the caller is not authorized.
+ /// 查询在线连接列表,仅返回给调用方,不向消息订阅者广播;查询被禁用或调用方未获授权时返回 null
+ /// Queries the online connections for the caller only, without broadcasting them to dispatch subscribers. Returns null when queries are disabled or the caller is not authorized.
///
public Task GetConnectionSnapshot()
=> ConnectionHandler.GetSnapshotAsync(Context, options, services);
diff --git a/src/middleware/BootstrapBlazor.Middleware/ConnectionHandler.cs b/src/middleware/BootstrapBlazor.Middleware/ConnectionHandler.cs
index 520949a8..1a76b2ef 100644
--- a/src/middleware/BootstrapBlazor.Middleware/ConnectionHandler.cs
+++ b/src/middleware/BootstrapBlazor.Middleware/ConnectionHandler.cs
@@ -24,12 +24,6 @@ public static async Task ReportHeartbeatAsync(HubCallerContext context, Cl
return false;
}
- if (client == null || string.IsNullOrWhiteSpace(client.Id) || client.Id.Length > 128 ||
- !Enum.IsDefined(typeof(WebClientDeviceType), client.Device))
- {
- throw new HubException("Invalid connection heartbeat.");
- }
-
var httpContext = context.GetHttpContext() ?? throw new HubException("The connection context is unavailable.");
client.Ip = httpContext.Connection.RemoteIpAddress.ToIPv4String();
client.UserName = context.User?.Identity is { IsAuthenticated: true } identity ? identity.Name : null;
@@ -47,6 +41,12 @@ public static async Task ReportHeartbeatAsync(HubCallerContext context, Cl
}
public static async Task GetSnapshotAsync(HubCallerContext context, BootstrapBlazorHubOptions options, IServiceProvider services)
+ {
+ var service = await GetConnectionServiceAsync(context, options, services);
+ return service == null ? null : new ConnectionSnapshot(service.Count, service.Connections);
+ }
+
+ private static async Task GetConnectionServiceAsync(HubCallerContext context, BootstrapBlazorHubOptions options, IServiceProvider services)
{
if (!options.EnableConnectionSnapshots)
{
@@ -65,11 +65,6 @@ public static async Task ReportHeartbeatAsync(HubCallerContext context, Cl
}
}
- var service = services.GetRequiredService();
- return new ConnectionSnapshot
- {
- Count = service.Count,
- Connections = service.Connections
- };
+ return services.GetRequiredService();
}
}