开发者

HTML client receiving continous stream of server output data

开发者 https://www.devze.com 2023-03-03 16:56 出处:网络
What would be best mechanism, for achieving ability, for users, that are logged in, receive messages, generated by server. As there is no way for a server, to send information to user, when it has new

What would be best mechanism, for achieving ability, for users, that are logged in, receive messages, generated by server. As there is no way for a server, to send information to user, when it has new message to deliver, a user browser should poll with some specific interval, to receive in response new messages, additionally, there should be a way for server, to not send messages, that are already delivered to user. You could draw a connections with something like public chat mechanism, but the thing I need is message delay as close to realtime and ability to handle about 100 users simultaniously, making least traffic possible. Additional note: data is needed only when user is online, no need to store that data in server, for other users to read "history".

In my mind, there are one way of achieving this - global "message box" where server puts all messages, user browser is constantly polling the server, to check, if last received message ID is equal to last message ID in message box.

The question is, if this is right way to do that, or there are another ways for such task开发者_开发问答s, as need for realtime data can be found everywhere: sensor data, multiplayer games, chat, stock market and more...


XEP-0124: Bidirectional-streams Over Synchronous HTTP (BOSH)

https://github.com/ssoper/jquery-bosh

Build a web-based notification tool with XMPP Write real-time web applications with XMPP, PHP, and JavaScript

Hope this helps.


Isn't pushing a better strategy? Keep a tcp connection open between server and browser and stream changes to the browser when new information is available.

Take a look at html 5 websockets. (which does exactly this)

heres a demo


Have you looked at Comet?

Comet is a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it.

If you search stackoverflow there is plenty of info about its use.

0

精彩评论

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