Search code examples
androidsmackasmack

Can't receive extension from message


I have problem when send a message via smack. I handled xml from sender device, it is:

<message id="qOP8c-14" to="52812" from="59271" type="chat"><body>dgggxhhhd</body><thread>52812</thread><datestamp xmlns="jabber:client">2013-08-28T03:59:41Z</datestamp></message>

and xml in receiver device is:

<message id="zqy34-12" to="[email protected]" from="59270" type="chat"><body>rmhxmxt,jxtj,dtj,</body><thread>59271</thread><datestamp xmlns="jabber:client"></datestamp></message>

You can see datestamp is empty. I'm using Asmack Library of Flowdalic (https://github.com/flowdalic/asmack).
Please help me. Is it the issue of library?


Solution

  • As this thread explains (https://stackoverflow.com/a/11141819/474002): Timestamp is not part of the regular messages. Therefore you cannot extract it.

    I think you could send a custom packet (use PacketExtension) to extend your message packet to include the timestamp information.

    Message message = new Message();
    DefaultPacketExtension yourExt = new DefaultPacketExtension("your_ext", "com:your:ext");
    yourExt.setValue("timestamp", YOUR_TIMESTAMP);
    messgae.addExtension(yourExt);