https://github.com/strophe/strophejs-plugin-archive
https://github.com/strophe/strophejs-plugin-archive
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/strophe/strophejs-plugin-archive
- Owner: strophe
- Created: 2017-01-25T13:42:07.000Z (over 9 years ago)
- Default Branch: archive
- Last Pushed: 2018-09-07T19:03:46.000Z (over 7 years ago)
- Last Synced: 2025-07-02T15:50:30.776Z (11 months ago)
- Size: 5.86 KB
- Stars: 1
- Watchers: 13
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# strophe.archive.js
strophe.archive.js is a plugin to provide Message Archiving
( [XEP-0136](http://xmpp.org/extensions/xep-0136.html) ).
## Notes on Browser support
If you want to support Browsers which do not support setISO8601 on a Date-Object (like e.g. FF 11), include iso8601_support.js, too.
## Usage
Make sure you include Strophe.rsm as well as Strophe.archive
Init Archive
# `connection` is Strophe.Connection
connection.archive.init(connection)
Retrieve Archive
var jid = 'username@your_xmpp_server';
connection.listCollections(jid, null, function(collections, responseRsm) {
// Now you can iterate over the collections. Here we retrieve
// all the messages contained in each collection.
collections.forEach(function(collection) {
collection.retrieveMessages(function(null, function(messages) {
// Your callback here to process all the messages in this collection.
});
});
});
Retrieve Archive with RSM
var cachedResponseRsm = null;
var jid = 'username@your_xmpp_server';
// Retrieve a max of 1 collections.
var rsm = new Strophe.RSM({max: 1});
// Fetch the first collection.
connection.listCollections(jid, rsm, function(firstCollection, firstRsm) {
// To demonstrate paging, we use the responseRsm to fetch the next collection.
var nextRsm = firstRsm.next();
connection.listCollections(jid, nextRsm, function(secondCollection, secondRsm) {
// Now we have access to the secondCollection here.
});
});
## ToDo
- write specs