On Wednesday, November 2, 2016 at 7:52:05 PM UTC-4, Dave S wrote:
>
> There are 2 mechanism in HTML5, I believe, but I'm only going to point you 
> at one for the moment:  Web Workers.
> <URL: 
> http://www.htmlgoodies.com/html5/javascript/working-with-web-workers-in-html5-powered-web-pages.html
> >
> <URL:
> http://www.htmlgoodies.com/HTML5/client/introduction-to-html5-web-workers-the-javascript-multi-threading-approach.html
> >
> <URL:
> http://www.htmlgoodies.com/html5/other/html5-tech-shared-web-workers-help-spread-the-news.html
> >
>
> With this mechanism, you'd spawn a web worker  to do jquery/ajax to check 
> when it was time to replace the content.  A couple of the examples 
> calculate Pi, and paste the results into the main page.
>

This approach is "short polling" (i.e., polling the server with quick 
requests at some interval to check for updates). Note, there is no 
particular reason this must be done with a web worker -- you can simply do 
it from the main web page, as it has been done since long before web 
workers existed. The idea is simply to keep making Ajax requests at regular 
intervals (e.g., every second). This approach might be fine, though 
depending on how many users are connected and how frequently they are 
checking, the server could get overwhelmed with requests. To reduce the 
load, you can decrease the request frequency, but then you increase the 
average latency between when a message is sent and when the recipient 
receives it.
 

> There is also web sockets in HTML5.
> <URL:
> http://www.htmlgoodies.com/html5/tutorials/making-html5-websockets-work.html
> >
> Gluon/contrib has websocket_messaging.py.
>

To handle the shortcomings of "short polling", you can instead use 
websockets (or long-polling, which maintains a long-held HTTP connection 
with the server until a new message is received). However, you need a web 
server and application that can handle many long-held open connections. To 
address this need, web2py includes websocket_messaging.py, as noted above 
-- it makes use of the Tornado web server to handle the websocket 
connections. You can also use various realtime messaging services (e.g., 
Fanout <https://fanout.io/>), or something like Pushpin 
<http://pushpin.org/> (an open source proxy server used by Fanout), which 
is probably a bit more robust and full-featured than websocket_messaging.py.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to