I am trying to build a simple chat app for learning purposes. How do I deal with time when working with chat messages?
I am using mongodb via mongoose.
I have done a test on telegram. I have switched off the internet on my computer and sent a message. I then waited for one minute to pass. Then, using the same account on the phone(while it was connected to the internet I sent another message to the same chat room. Then I turned on the internet on the computer, so that the messaged I 'sent' earlier can be sent over the internet. Here is where I get a bit confused. The time stamp on the message I sent via the computer is different in the phone and on the computer. On the computer the time stamp is the time I pressed send. On the phone it is the time it received the message after I turned on the internet on the computer. The message from the phone had the same time stamp on the phone and on the computer (as you would expect).
My questions are:
How is this possible? Is it possible that Telegram stores two time stamps, one for the time the message was sent and another for the time it was received?
Should the message time stamp be the time the message was sent or the time it was saved in the database? What are the advantages and disadvantages of doing it either way?
Aucun commentaire:
Enregistrer un commentaire