推送服务器实现技术?
我计划开发一个使用推送功能的解决方案。将有一个服务器和移动设备客户端应用程序。
我需要知道如何将消息从服务器推送到客户端。也就是说,我的客户端应用程序正在被动等待,直到来自服务器的消息。
从服务器推送消息背后的技术是什么?
客户端形式有Android、J2me、BB、iphone等
I'm planning to develop a solution which uses push functionality. There will be a server and mobile device client application.
I need to know how to push messages in to the client from the server. That is my client application is passively waiting until a messages comes from the server.
What is the technology behind pushing the messages from the server.
Clients are in the form of Android,J2me,BB,iphone etc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谷歌搜索“COMET”,你会得到很多链接。一般来说,您需要一个可以驻留请求并在有数据返回时接收它们的服务器框架。例如,一个基本的 Java Servlet 将为每个请求保留一个线程,如果您“停放”一个请求(通过执行一些等待),该线程将与该请求一起挂起。通过这种方式,您只能让与服务器中的线程一样多的客户端等待请求,这对于大型应用程序来说是不够的。
因此,至少,您需要一个可以在请求暂停时重用线程的系统。随着推送再次流行,支持它的框架正在蓬勃发展,因此如果没有更多上下文,就很难推荐某个服务器/框架。
话虽如此:-),在 Play Framework (http://www.playframework.org/) 中有一个示例聊天应用程序,它使用“push”的三种变体。如果有的话,值得仔细阅读代码(假设您了解 Java)来感受各种解决方案。
Google for "COMET", you'll get a lot of links. Generally speaking, you want a server framework that can park requests and pick them up when they have data to return. For example, a basic Java Servlet will keep a thread per request, and if you "park" a request (by doing some wait), the thread is suspended along with the request. In this way, you can only have as many clients waiting on a request as you can have threads in the server, which is not enough for big apps.
So, at the very least, you want a system where threads can be reused as requests are paused. As push is becoming popular again, frameworks to support it are blooming, so without more context it is hard to recommend a certain server/framework.
Having said that :-), in the Play Framework (http://www.playframework.org/) there is a sample chat application that uses three variations of "push". If anything, it's worth perusing the code (assuming that you know Java) to get a feel for the various solutions.
看看 HTML5 Web 套接字。这是一种打开
原始 TCP 套接字套接字的方法,其工作方式类似于 TCP 套接字 (有一些限制),但通过 HTTP 从浏览器发起,从而实现真正的双向通信。许多现代浏览器都支持它,包括当前的 iOS 浏览器。 Android 不支持它,但您可以依靠 Flash 像素。编写一个管理套接字并将所有信息来回传递给 Javascript 的 Flash 文件非常容易。如果您有兴趣,我想我什至可以为您挖掘一些代码。Have a look at HTML5 web sockets. It's a way of opening a
raw TCP socketsocket that works like a TCP socket (with some limitations) but is initiated over HTTP, from the browser, enabling true two-way communication. It's supported in many modern browsers, including the current iOS browser. Android doesn't support it, but there you can fall back on a Flash pixel. It's quite easy to write a Flash file that manages the socket and passes all the information back and forth to Javascript. If you're interested I think I might even have some code I could dig out for you.