您能否从 WCF 服务向客户端发送数据,而客户端无需调用该服务?

发布于 2024-12-20 12:02:45 字数 242 浏览 5 评论 0 原文

假设我想编写一个点对点聊天应用程序。我使用 WCF 服务作为客户端“登录”的服务器,以便它们可以找到彼此的 IP 地址和端口。

好吧,还说我的客户端应用程序中有一个文本框,显示所有在线用户。每次用户登录或注销时,我想更新此“谁在线”文本框,以便仅显示当前在线用户。

因此,一旦用户登录或退出,服务器需要向所有客户端发送信息。但似乎WCF只能在响应请求时发送数据......

我在这里遗漏了什么吗,WCF能够处理这种情况吗?

Say I want to write a peer to peer chat application. And I use a WCF service as the server that the clients 'log in' to so that they can find each other's ip addresses and ports.

Well, say also I have a textbox in my client application that display all users that are online. Everytime users log in or out I want to update this 'Who's online' textbox so that only the currently online users are shown.

So the server needs to send information out to all clients once a user logs in or out. But it seems WCF can only send data when responding to requests....

Am I missing something here, is WCF able to handle this situation?

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

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

发布评论

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

评论(2

鯉魚旗 2024-12-27 12:02:45

有多种方法可以解决此问题,这些可能是最常见的:

  1. 使用发布/订阅,如下所示 好文章
  2. 将所有当前登录的用户保存在存储中 - 数据库或您喜欢的任何内容,并从用户端查询它。

There are several approaches to this problem, these would probably be the most common:

  1. Use publish/subscribe, like in this good article.
  2. Keep all the currently logged users in a storage - a database or whatever you'd prefer, and query it from the users' side.
捶死心动 2024-12-27 12:02:45

我认为您需要双面打印服务。

I think you need a duplexing service.

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