0

Is it possible to add server timestamp in the messages sent by the ejabberd server ? This will help in synchronizing the Server and Client clock times. I am facing difficulties in trying to retrieve the message history in an MUC chat.

Scenario:

Lets say that the Server time is T100 and that the client's clock is 10 seconds behind the server time(Lets call this time T90).

At T100, the server sends an message M1 to the client. The client receives this message at time T90(Clients local time).

Next the client goes offline and tries to rejoin the group. The client requests for all messages after time T90 (since the last received message M1 was received by client at T90).

The server sends M1 back to the client again because M1 has an timestamp of T100.

Thanks,

Mithun Raman
  • 309
  • 4
  • 13

1 Answers1

0

MAM messages have ids. You can use those ids to paginate in archive, retrieve messages and undupe.

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
  • I am not sure how MAM ids will help here. Lets say that the client has joined a room & has asked for the room history & the server sends a single message with MAM id 'M1' back to the client. Next the client receives 100 active messages from the room. The client now disconnects and tries to join the room again asking for all messages after MAM id 'M1'. The client would receive atleast 100 messages from the room history out of which the first 100 would be duplicates. Couple of questions. Are Stanza Ids & MAM Ids the same? Would it be okay to add a hook that adds timestamp to all chat messages? – Mithun Raman Jan 15 '16 at 09:32
  • The id are different but if you are using MAM to retrieve messages, then do not get history message, you can ask for zero history messages when you join. – Mickaël Rémond Jan 15 '16 at 20:30
  • Well i will definitely take a look into that. Currently i have managed to write a hook to that adds time stamp to all group chat messages :) – Mithun Raman Jan 19 '16 at 04:25
  • @MithunRaman Hi can you please tell how you have managed to add a timestamp in all the group messages, because if a message is delivered without delay no delay tags will come only an archived tag will come with an id. – Mohit Mathur Jul 27 '16 at 08:09