[Haskell-cafe] Happstack events and web page refreshing

Corentin Dupont corentin.dupont at gmail.com
Wed Jan 19 15:02:51 CET 2011


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 <v.dijk.bas at gmail.com> wrote:

> On 17 January 2011 21:50, Jeremy Shaw <jeremy at n-heptane.com> 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 at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110119/0730a01d/attachment.htm>


More information about the Haskell-Cafe mailing list