TimeOverlord
A message id is generated from the timestamp, but Telegram's server may have a slightly different time than ours. TimeOverlord is here to fix that, and will keep the time difference between each of data center and us.
Weak message id
A weak message id is a message id generated from the timestamp, but following the mtproto specifications, a message id is unique, it means that two messages (say A and B) being send at the same time (approximately or in the same container) will have two different message id.
How does it work?
- Generate a message id for the first message (say A)
- Generate a weak message id for the second message (B)
- A and B will have the same message id because being sent at the same time
- Increment B by 4 because it comes after A (message id must be modulo 4)
If we have 3 messages, we'll have:
messageId(C) = messageId(B) + 4
messageId(B) = messageId(A) + 4
So when generating a message id, you follow the following algorithm:
- Generate a weak message id
- Check the latest generated message id
- Return the max between the weak message id and the latest generated message id + 4
Updated less than a minute ago
