How to get timestamp of incoming xmpp message?

后端 未结 6 1923
梦谈多话
梦谈多话 2021-02-04 05:05

I am using aSmack library to communicate with remote xmpp server. I am able to send/receive messages, but I want to get timestamp of incoming message.

Could you tell me

6条回答
  •  梦毁少年i
    2021-02-04 06:05

    Although in part a blend of the other answers already here, I would present the answer as follows...

    XMPP is "realtime"... although that term can mean a lot of different things to different people, in general you can safely assume that you receive messages (almost) as soon as they're sent - all XMPP software is designed around fulfilling this goal.

    However there is no actual guarantee about the end-to-end latency. In general practice you'll typically always receive a message far less than a second after it was transmitted by the sender, though network conditions can affect this.

    In some cases the message will be temporarily delayed, such as when a new server-to-server connection needs to be established. This can take up to a few seconds generally, depending again on network conditions and the method of authentication used between the servers.

    A message may also be held up if the recipient is offline - the recipient's server may hold the message in an "offline message" store, until it can deliver it when the the recipient comes online.

    Because of the general instant delivery of XMPP messages, timestamps are generally not included in the message itself, as that information is useless (and assumes clocks are all correct).

    In cases where the message is knowingly delayed though, such as in the examples above, the entity that delays the message may insert a tag into the message indicating the original time of the message. This is detailed in XEP-0203: Delayed Delivery.

提交回复
热议问题