5

A Countdown Timer is started from Node.js Server, and when starting a countdown timer a socket event(with countdown ~20s) is broadcasted to all connected clients(Android App) using Socket.IO.

And sometimes due to slow internet connection or due to some other reason, some clients receive the broadcasted message delayed and the countdown timer starts delayed in those devices. The countdown timer in server and the android app are not synced.

What should I do to sync the countdown timer with server from Android App?

Valamburi M
  • 692
  • 4
  • 17

2 Answers2

3

Instead of passing Countdown time you should pass expire time value and you have to get countdown time by your self. In this way your countdown time will be same on the server and mobile.

VikasGoyal
  • 3,308
  • 1
  • 22
  • 42
  • 1
    Okay, I'll send the expire time of the countdown, but How can I be sure that the Android App knows the exact server's current time? The duration of countdown will be around 20 seconds. So it is very necessary that I know the exact server time and the expiry time, in order to make your solution to work out. – Valamburi M Nov 19 '15 at 11:30
  • 1
    You can take time in UTC it will same on server and mobile.Maintain your time zone properly and you will not phase the problem. – VikasGoyal Nov 19 '15 at 11:54
  • If the mobile has incorrect timezone, then I would face some issues Am I right? Is it necessary to check the android phone has correct time and timezone. – Valamburi M Nov 19 '15 at 12:11
  • You will always pass the time api for countdown in UTC format and in Android app you treat that timestamp value is in UTC if you treat it other than UTC it will give you wrong output. – VikasGoyal Nov 19 '15 at 12:26
0

its happens with push notification but easy way to use sync adapter in android app. which sync all client at same time.

here is full description of sync adapter

comment below, if you have any question for me!

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177