VS Blazor Server应用程序模板:服务器到客户端SignalR通信

发布于 2025-02-06 04:09:23 字数 92 浏览 1 评论 0原文

由于Blazer Server已经与客户端建立了SignalR连接,因此在不创建新的SignalR连接的情况下,服务器可以在BlazorHub中点击并将通知推向客户端吗?

Since blazer server already establish a signalr connection with it's client, without creating new signalr connection is there any simple way for server to tap in blazorhub and push notification to client?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风吹 2025-02-13 04:09:23

每次您致电stateHaschanged时,如果需要,DOM都会更新。

您可以使用计时器或其他一些事件触发此更新。

public async Task NewMessageAsync(Message message, CancellationToken cancel)
{
      if (_tenant.MessageMatchTemplate(message, _template))
      {
          messagesDisplayList.Add(message.data);
          await InvokeAsync(StateHasChanged);
      }
}

此处的完整聊天示例

https://github.com/iso88859/threadmessaging

Each time you call StateHasChanged the DOM is updated if needed.

You can trigger this update with a timer or with some other events.

public async Task NewMessageAsync(Message message, CancellationToken cancel)
{
      if (_tenant.MessageMatchTemplate(message, _template))
      {
          messagesDisplayList.Add(message.data);
          await InvokeAsync(StateHasChanged);
      }
}

Full chat example here

https://github.com/iso8859/ThreadMessaging

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文