angularjs - Patterns for handling missed push events? E.g. chat messages sent while offline or in sleep mode -
angularjs - Patterns for handling missed push events? E.g. chat messages sent while offline or in sleep mode -
i'm writing app uses websockets via pusher. ruby on rails + angularjs app should apply stack, really.
i realized app doesn't handle missed force events, , i'm interested hear established patterns are.
my app isn't chat, let's pretend is.
when page loads, gets lastly 100 chat messages db , shows them.
whenever new chat message comes in, server pushes new message clients via pusher/websockets.
but! if client offline or in sleep mode when force comes in, can miss messages.
what's pattern handling that?
i have vague ideas around detecting client "waking up" , either forcing total page reload or requesting events since timestamp or since event, i'm not sure way of determining "waking up" without adding polling mix. maybe using pusher's client presence or connection states features, detecting when user (re-)connected?
i haven't been able find way of getting history of events pusher, guess have store myself, send them client only.
you mentioned when page loads, client gets lastly 100 messages database. that, understand you, in add-on pushing out messages via pusher, maintain track of messages in database.
so when client comes online, should check same endpoint check when visiting page first time. can compare returned set against messages have cached on client , see if missed anything.
i'm not familiar pusher api, seems me can hear unavailable
or disconnected
events. set flag when see events, wait connection reestablished , pull history server 1 time again , compare against local cache.
angularjs websocket pusher
Comments
Post a Comment