check, if comet server push was successful

25 views
Skip to first unread message

Schulzki

unread,
Apr 8, 2015, 5:45:40 PM4/8/15
to lif...@googlegroups.com
Hi,

I have a Rest service based on Lift that pushes messages to the client browser using Lift's comet
implementation. I would like to detect, if the message was (technically) delivered successfully.
If, for example, the client browser is offline, or was closed, I would like to cache the message and deliver it later,
when the client is back (I already have a solution for that).

Thanks,
Stefan

Donald McLean

unread,
Apr 9, 2015, 8:49:33 AM4/9/15
to liftweb
Part of the update could be an AJAX call to a server side function.

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Family photographs are a critical legacy for
ourselves and our descendants. Protect that
legacy with a digital backup and recovery plan.

Schulzki

unread,
Apr 9, 2015, 10:03:41 AM4/9/15
to lif...@googlegroups.com
Yes, I actually was about to implement a confirmation service, 
but it feels a little bit like a waste of ressources: another server call,
 some logic to reference the original event and so on. 

It would be much easier if there is some response similar to the 
onError" and "onSuccess" functions on a client side ajax call.

Thanks & regards, Stefan 

Antonio Salazar Cardozo

unread,
Apr 19, 2015, 4:36:56 PM4/19/15
to lif...@googlegroups.com
Lift already guarantees this over the lifetime of this comet actor using lastListenerTime,
which is the last version that we know the client saw (based on the last request we got
from it). Though lastListenerTime seems to indicate this is a timestamp, it's actually a
monotonically increasing number. Currently, the version is privately associated with its
respective JsCmd in the deltas variable in CometActor; the only thing that has access
to that information is the delta pruner (since Lift 3.0-M1 I think). The delta pruner is
periodically handed the comet actor (which will reveal the latest confirmed listener time)
and the list of deltas the actor is holding on to.

You could use this to keep your own updated copy of the deltas and then, at CometActor
shutdown time (in localShutdown), check the current lastListenerTime and stash all as-
yet-unacked deltas in the database or something. It's a tad hacky, but doable and piggybacks
on Lift's already-existing functionality for message delivery confirmation.

Notably, keep in mind that you could get into a situation where the message did arrive at
the client, but the connection failed before the client launched its followup request, so you
think certain messages did not arrive when in fact they did.

Also reiterating: if the user stays on the page and the session/CometActor don't expire, Lift's
comet mechanism will take care of re-transmitting missed data during transient connection
loss. You only need your own solution if you're trying to do cross-session remembering of
things that didn't get delivered, which seems like an odd thing to do (since if the session's
lost, you'd just reload the page to its most current state).
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages