1

Using the sinch instant messaging for android, how to sync so that messages appear in the correct order, if two devices have different clocks?

When I read the docs for Message#getTimestamp(), they state that it "returns the server side timestamp of the Message", which seems promising. It did not work, though: in practice, it appears that onMessageSent() is called with the local time while onIncomingMessage() is called with the server time.

Imagine that device 1 and device 2 have different clocks and are chatting with eachother, and that device1 is ahead of device2. For example, device1 has 7:15 while device2 has 7:00. The server time is also 7:00. These were my findings:

  • device1 sends "First message!"
  • device1: onMessageSent() is triggered. m.getTimestamp() returns 7:15 (the local time for device1)
  • device2: onIncomingMessage() is triggered. m.getTimestamp() returns 7:00 (the server time, and the local time for device2)

Shouldn't getTimestamp() always return server-side time? Am I missing something?

aom
  • 21
  • 4

0 Answers0