archive id <stanza-id/> 被archived过的消息,server要给它加上stanza-id Example 1. Client receives a message that has been archived
1 2 3 4 5 6 7
<messageto='juliet@capulet.lit/balcony' from='romeo@montague.lit/orchard' type='chat'> <body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body> <stanza-idxmlns='urn:xmpp:sid:0'by='juliet@capulet.lit'id='28482-98726-73623' /> </message>
stanza-id: archive ID
查询
1. A user queries their archive for messages
用消息UID查询
‘urn:xmpp:mam:2’ namespace, indicating the UID of the first and last message of the (possibly limited) result set.
Example 7. Querying the archive for all messages in a certain timespan¶ <iqtype='set'id='juliet1'> <queryxmlns='urn:xmpp:mam:2'> <xxmlns='jabber:x:data'type='submit'> <fieldvar='FORM_TYPE'type='hidden'> <value>urn:xmpp:mam:2</value> </field> <fieldvar='start'> // UTC格式 <value>2010-06-07T00:00:00Z</value> </field> <fieldvar='end'> <value>2010-07-07T13:23:54Z</value> </field> </x> </query> </iq>
如果end 缺失, server会自动认为是最近的消息的存储时间
1 2 3 4 5 6 7 8 9 10 11 12 13
Example 8. Querying the archive for all messages after a certain time¶ <iqtype='set'id='juliet1'> <queryxmlns='urn:xmpp:mam:2'> <xxmlns='jabber:x:data'type='submit'> <fieldvar='FORM_TYPE'type='hidden'> <value>urn:xmpp:mam:2</value> </field> <fieldvar='start'> <value>2010-08-07T00:00:00Z</value> </field> </x> </query> </iq>
Example 9. A query using Result Set Management¶ <iqtype='set'id='q29302'> <queryxmlns='urn:xmpp:mam:2'> <xxmlns='jabber:x:data'type='submit'> <fieldvar='FORM_TYPE'type='hidden'> <value>urn:xmpp:mam:2</value> </field> <fieldvar='start'> <value>2010-08-07T00:00:00Z</value> </field> </x> <setxmlns='http://jabber.org/protocol/rsm'> <max>10</max> </set> </query> </iq>
Example 10. Server responds to client with limited results using RSM¶ <!-- result messages --> <iqtype='result'id='q29302'> <finxmlns='urn:xmpp:mam:2'> <setxmlns='http://jabber.org/protocol/rsm'> <firstindex='0'>28482-98726-73623</first> <last>09af3-cc343-b409f</last> <count>20</count> </set> </fin> </iq>
Example 11. A page query using Result Set Management¶ <iqtype='set'id='q29303'> <queryxmlns='urn:xmpp:mam:2'> <xxmlns='jabber:x:data'type='submit'> <fieldvar='FORM_TYPE'type='hidden'><value>urn:xmpp:mam:2</value></field> <fieldvar='start'><value>2010-08-07T00:00:00Z</value></field> </x> <setxmlns='http://jabber.org/protocol/rsm'> <max>10</max> <after>09af3-cc343-b409f</after> </set> </query> </iq>
server返回最后一页消息,会在 fin里头带上complete属性,值为ture
1 2 3 4 5 6 7 8 9 10 11 12
Example 12. Server completes a result with the last page of messages¶ <!-- result messages --> <iqtype='result'id='u29303'> <finxmlns='urn:xmpp:mam:2'complete='true'> <setxmlns='http://jabber.org/protocol/rsm'> <firstindex='0'>23452-4534-1</first> <last>390-2342-22</last> <count>16</count> </set> </fin> </iq>
Example 16. Server returns two matching messages¶ <messageid='aeb213'to='juliet@capulet.lit/chamber'> <resultxmlns='urn:xmpp:mam:2'queryid='f27'id='28482-98726-73623'> <forwardedxmlns='urn:xmpp:forward:0'> <delayxmlns='urn:xmpp:delay'stamp='2010-07-10T23:08:25Z'/> <messagexmlns='jabber:client' to='juliet@capulet.lit/balcony' from='romeo@montague.lit/orchard' type='chat'> <body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body> </message> </forwarded> </result> </message>
<messageid='aeb214'to='juliet@capulet.lit/chamber'> <resultxmlns='urn:xmpp:mam:2'queryid='f27'id='5d398-28273-f7382'> <forwardedxmlns='urn:xmpp:forward:0'> <delayxmlns='urn:xmpp:delay'stamp='2010-07-10T23:09:32Z'/> <messagexmlns='jabber:client' to='romeo@montague.lit/orchard' from='juliet@capulet.lit/balcony' type='chat'id='8a54s'> <body>What man art thou that thus bescreen'd in night so stumblest on my counsel?</body> </message> </forwarded> </result> </message>