[Haskell-cafe] Happstack events and web page refreshing
jeremy at n-heptane.com
Mon Jan 17 17:41:14 CET 2011
The problem is that clients are not 'connected' to the web server. The
way it works (more or less) is:
1. client connects to server and sends a Request
2. server sends a Response
3. connection is terminated.
So, once the page has been loaded there is no connection between the
web-server and the client. Hence there is no way for the server to
send anything to the clients.
In HTML 5, there is something known as web sockets with does allow you
to have a persistent connection to the clients. However, it does not
yet have broad browser support. In fact, some browsers have
temporarily removed support due to a security flaw in the design
There are a variety of hacks collectively known as 'comet' for trying
to create a persistent connection on top of the existing HTTP 1.1
That deals with trying to have the server push updates to the client.
A different approach is to have the clients pull new data from the
server by polling the server for changes every now and then. But that
depends on how much latency you can afford for the updates. For
example, if updating only once a minute is fine versus must update
Once you decide how to get the data to the client, then you can figure
out how to track changes to the MACID database.
On Jan 17, 2011, at 4:58 AM, Corentin Dupont wrote:
> Hello again,
> I have another question for happstack users/experts:
> I have a program with happstack-state and a web server with
> What I'd like is, whenever the MACID state is changed, that the web
> page is refreshed for every clients
> connected on the web server.
> So I think the question is 2 fold:
> - How to add an event handler on happstack-state for that?
> - How to ask to the web server to refresh every clients?
> I did not found infos about that in the API.
> Thanks a lot,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe