开发者

Can server hits the client directly

I have a small requirement in PHP as below. Some thing like chat.

For eg there are 2 users A & B.

Whe开发者_Python百科n "A" clicks on "Chat" link. "B" should automatically gets one javascript popup.

Is there any way of doing this except following. - One JS script runs continuously with AJAX. I dont want to happen client-server interaction continuously.

Is there any way for server sending status to browser directly?.

Thanks in advance.


You can do it the other way, instead of Ajax use Comet. That way the server pushes data to the client without the client expecting it. The Facebook chat uses this technique.


Are you worried about wasting bandwidth? Why not try out XMPP? There are php libraries as well.


You can either use polling (the JavaScript client keeps checking with the server every once in a while using AJAX) or use something like a Java Applet which would establish a separate connection with server and keep it on for communicating back and forth. If you use a Java Applet, then you should probably use server side Java as that would be the most effective.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜