
Hi,
I've not really followed the thread, but on the client side, for
long-polling, you issue an XMLHttpRequest that will receive an answer
from the server only when the server has something to push to the
client (maybe done with a thread waiting on an MVar). XHR is
asynchronous as you have to supply a callback to process the server's
response.
Usually an XHR request is done from an already loaded page and will
update part of that page with the content of the server's response. So
no blank page.
(So no timer needed either, this is done asynchronously with callbacks.)
HTH,
Thu
2011/1/19 Corentin Dupont
Thanks. There seems to be several technologies to realize this push or polling.
Is what you explained feasible on the user's side of happstack-server (I mean, if I can do it myself)? If I take an empty MVar in my ServerPartTs, which are read over client's request, I think that nothing will be sent back to the browser and it will remain blank! Is that to be combined with an HTTP refresh timer on the client side?
By sessions, you mean sessions that I create myself for every client connected?
Regards, Corentin
On Wed, Jan 19, 2011 at 2:21 PM, Bas van Dijk
wrote: On 17 January 2011 21:50, Jeremy Shaw
wrote: On Jan 17, 2011, at 2:19 PM, Corentin Dupont wrote:
Indeed, I tried with <META HTTP-EQUIV="Refresh" CONTENT="n"> ? and it's unusable. It make blink the page, ungrey the "stop" button for a second and make the fields loose the focus so it's impossible to type in.
I'll try with XMLHTTPRequest.
Right. Using the jQuery library should make it easier to do ajax requests and modify the DOM on the fly, http://jquery.com/ - jeremy _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
A nice variation of polling is "long polling":
http://en.wikipedia.org/wiki/Push_technology#Long_polling
This can easily be accomplished in Haskell by having an MVar per session. Initially an empty MVar is created per new session. When a client makes a request, the server thread that handles the request takes the MVar belonging to the session. This thread will block until the MVar is filled. When the server has an update it will fill all the MVars. This causes all the blocked threads to continue with sending a response to the client notifying it about the update.
Like Jeremy said it's a good idea to make these update requests asynchronous.
Regards,
Bas
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe