浏览器中的独立 php jabber 客户端,无需 javascript
有没有什么方法可以在没有 JavaScript 的情况下维护从 php 到 jabber 服务器的流以保持客户端的活动?
一些低端手机不支持javascript,因此保持与服务器的永久连接是关键问题?有什么技巧吗?
Is there any way to maintain stream from php to the jabber server without javascript to keep the client side live?
Some low end mobile do not support javascript, so to maintain permanent connection to server is key question? any hacks?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PHP 是一种服务器端技术,因此维持从服务器端到 XMPP 服务器的连接是没有问题的。
但是,如果您无法在客户端使用 Javascript,则唯一的选择是定期刷新网页,然后在服务器端排队的任何事件都将通过新生成的 HTML 提供给客户端。
也许您可以通过将元刷新设置为 0 来实现 Comet 或 BOSH 风格的长轮询,其中 Web 服务器返回所有当前聊天信息,但直到某个时间段结束后才完全完成响应。通过了。
这是否可行可能取决于您希望支持哪些客户端 - 某些移动浏览器可能不会在内容进入时进行部分渲染,而是等待整个请求完成。
此外,如果连接在任何时候被中断,您就会陷入困境,因为浏览器不知道要进行元刷新。可能存在某种基于帧的解决方案,可以将一个框架重新加载到另一个框架中?
玩得开心! ;)
PHP is a server-side technology, so there's no problem there to maintain a connection from the server-side to the XMPP server.
However, if you cannot use Javascript on the client side, your only option is to periodically refresh the web page, where any events queued on the server side will then be given to the client via the newly-generated HTML.
Possibly you could implement a type of Comet- or BOSH-style long-polling by having a meta-refresh of 0, where the web server returns all the current chat info, but doesn't quite complete the response until a certain time period has passed.
Whether that's feasible or not probably depends on which clients you wish to support — it's possible that some mobile browsers don't do partial rendering as the content comes in, they wait for the entire request to complete.
Also, if the connection was to be interrupted at any point, you're stuck, as the browser wouldn't know to do a meta refresh. Possibly there's some sort of frames-based solution to that where one frame reloads into another?
Have fun! ;)