如何进行 HTTP 服务器推送——也就是我需要 STOMP、AMPQ 等吗?

发布于 2024-08-06 16:54:55 字数 114 浏览 6 评论 0原文

我正在编写一组Web服务,其中一个需要实现服务器推送。

客户端将是原生 Objective-C。我希望它尽可能简单、快速、轻量。传输的数据将为 JSON。是否可以在不使用消息代理的情况下完成此操作?

I am writing a collection of web services, one of which needs to implement server push.

The client will be native Objective-C. I want this to be as simple, fast, and lightweight as possible. The data transmitted will be JSON. Is it possible to do this without using a message broker?

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

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

发布评论

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

评论(1

屋檐 2024-08-13 16:54:55

有一种名为 COMET 的 HTTP 技术,其中客户端启动一个线程,使对 HTTP 服务器的潜在的非常长的请求。每当服务器想要向客户端发送某些内容时,它就会发送对此请求的响应。客户端处理此响应并立即向服务器发出另一个长期请求。通过这种方式,服务器可以在客户端的主执行线程中发生其他事情的同时发送信息。服务器发送的信息可以是您喜欢的任何格式。 (事实上​​,对于在 Web 浏览器中使用 Javascript 库执行 COMET 的客户端来说,JSON 是完美的。)

@DevDevDev:确实,COMET 最常与支持 Javascript 的浏览器相关联,但我认为不必如此。您可以查看 iStreamLight,它是一个用于 iPhone 的 Objective-C 客户端,可连接到彗星服务器。 本次采访 与作者。

There's an HTTP technique called COMET in which the client spins up a thread that makes a potentially very long-lived request to the HTTP server. Whenever the server wants to send something to the client, it sends a response to this request. The client processes this response and immediately makes another long-lived request to the server. In this way the server can send information while other things happen in the client's main execution thread(s). The information sent by the serve can be in any format you like. (In fact, for clients in a web browser doing COMET with a Javascript library, JSON is perfect.)

@DevDevDev: It's true that COMET is most often associated with a Javascript-enabled browser, but I don't think it has to be. You might check out iStreamLight, which is an Objective-C client for the iPhone that connects to COMET servers. It's also discussed in this interview with the author.

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