为少量客户端实现服务器端推送
对于我正在开发的 Web 应用程序,我有以下要求:
- 客户端需要能够通过 Web 浏览器登录。
- 登录后,他们将能够
- 更改配置(正常请求/响应)
- 将能够接收服务器发送的警报(服务器端推送)
现在,问题是如何实现警报。我首先想到使用一些长轮询方法(Comet),但由于客户端数量肯定会限制在 5-10 个,所以我现在考虑采用更简单的方法。
我有哪些选择?让客户端轮询服务器可以吗?
For an web application I am working on I have the following requirements:
- Clients need to be able to log in via a web brower.
- After logging in, they will be able to
- change configurations (normal request/response)
- will be able to receive alarms sent by the server (a server side push)
Now, the question is how to implement the alarms. I first thought of using some long polling approach (Comet), but as the amount of clients will definitely belimited to 5-10, I'm now thinking to go with a simpler approach.
What are the options I have? Would it be okay to just let the clients poll the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
5-10个客户?我会让他们轮询服务器。无需对此进行过度设计。
5-10 clients? I would just have them poll the server. No need to over engineer this.
您可以考虑使用 Adobe Flash 对象打开到服务器的套接字连接。
这将允许客户端和服务器实际“连接”,从而让您在服务器上知道您确实已连接,或者连接何时丢失。
您还可以将一个简单的心跳系统与此结合起来,允许每秒或几秒钟进行“准备就绪”验证。
顺便说一句...您确定 Web 应用程序(而不是本机 GUI 应用程序)是适合此操作的平台吗?
You could consider using an Adobe Flash object to open a socket connection to the server.
This would allow the client and server to actually be "connected", therefore letting you know on the server that you are indeed connected, or when the connection is lost.
You could also tie in a simple heartbeat system into this, allowing "readiness" verification every second or few.
As a side note... Are you sure a web app is the right platform for this, as opposed to a native GUI application?