实时检索在线用户,通过 Identity Blazor (Server / WebAssembly) 进行身份验证

时间:2021-07-06 07:51:30

标签: server blazor identity webassembly

我正在 Blazor(服务器/WebAssembly)中创建聊天,使用 SignalR 我平静地收到收到消息的通知。 如何查看谁是在线用户?

1 个答案:

答案 0 :(得分:1)

使用信号器,您可以覆盖集线器 OnConnectedAsyncOnDisconnectedAsync :

public async override Task OnConnectedAsync()
{
    await notificationsService.ConnectAsync(this.ToCallerContext());
    await base.OnConnectedAsync();
}
public async override Task OnDisconnectedAsync(Exception exception)
{
    await notificationsService.DisconnectAsync(this.ToCallerContext());
    await base.OnDisconnectedAsync(exception);
}