Inform client about changes


#1

Hey guys,

I’ve got a little question…maybe i searched with the wrong keywords but i couldn’t find anything.

My scenario is, that there is a client which stores data from the rest api. Now when some other client removes one entry…how does my client gets informed about that he should delete that local entry too? Are there any possibilities ro retrieve notifications or should i use events or something?
Which is the common way to solve that?

Best regards and thanks for any help


#2

@Kphil80

I think there are 2 ways to handle this. If your client can receive push notifications, Dreamfactory can plug into an Amazon SNS service and you can send push notifications to any number of clients. Amazon SNS is currently free for the first 1,000,000 messages/month. My understanding is you “wrap” the endpoint in a custom script that calls an endpoint for the data manipulation and another for the push messages.

If you’re dealing with two browsers, the easiest is to just check on a loop for changes if the dataset is a manageable size. Or add a “modified” timestamp column and just select the most recent ones + the total count with the loop. That should catch all changes, and is the most common solution I’ve seen.


#3

Thanks for your help.

Maybe a combination of both will do the trick…
A modified timestamp will let the client make updates, but he will never know that he has to delete a record, because the record doesn’t exists anymore. (Deleted-Flags are no option…too much data trash) …and asking for the existence of a record every time is no option too. Maybe I should consider making updates with the timestamp and additionally let the client over the amazon service know when a record was deleted.

Or am I wrong?


#4

Hi guys,
I had the same problem. My solution to this is to maintain two channels of communication:

  • api calls to manage the data
  • socket connection to update realtime the clients that are connected
    I am using the socket just to inform clients about critical changes. After the change I just send out a message with the change and all the clients connected refresh their data based on that.

This is the library that I’m using for the socket http://socket.io/
I’ts really easy to implement it and it has a really low impact on the performance.