{"id":23014807,"url":"https://github.com/strophe/strophejs-plugin-rsm","last_synced_at":"2025-08-14T07:31:36.773Z","repository":{"id":57372952,"uuid":"80017717","full_name":"strophe/strophejs-plugin-rsm","owner":"strophe","description":null,"archived":false,"fork":false,"pushed_at":"2017-07-14T21:07:28.000Z","size":7,"stargazers_count":2,"open_issues_count":1,"forks_count":6,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-09T15:07:40.174Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strophe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-25T13:38:33.000Z","updated_at":"2023-01-23T14:24:39.000Z","dependencies_parsed_at":"2022-08-29T14:20:34.065Z","dependency_job_id":null,"html_url":"https://github.com/strophe/strophejs-plugin-rsm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strophe%2Fstrophejs-plugin-rsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strophe%2Fstrophejs-plugin-rsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strophe%2Fstrophejs-plugin-rsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strophe%2Fstrophejs-plugin-rsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strophe","download_url":"https://codeload.github.com/strophe/strophejs-plugin-rsm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229636823,"owners_count":18102354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-15T11:09:52.358Z","updated_at":"2024-12-15T11:09:52.918Z","avatar_url":"https://github.com/strophe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strophe.rsm.js\n\nPlugin for [strophe.js](https://www.npmjs.com/package/strophe.js) providing Result Set Management (RSM) [XEP-0059](http://xmpp.org/extensions/xep-0059.html).\n\n## Install\n\n```bash\nnpm install strophejs-plugin-rsm\n```\n\n### ES6\n\n```js\nimport 'strophejs-plugin-rsm';\n```\n\n### Browser\n\n``` html\n\u003cscript src=\"strophe.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"strophe.rsm.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nMake sure [Strophe](https://www.npmjs.com/package/strophe.js) is installed and the plugin is imported into your app. With RSM is available to do paged stanza requests like so:\n\n```js\nrequire('strophejs-plugin-rsm');\n\nvar connection = new Strophe.Connection('wss://...');\n\nvar options = {\n  before: '',\n  isGroup: false,\n  max: 50,\n};\n\nvar messages = [];\n\nvar queryid = connection.getUniqueId();\nvar stanza = $iq({ type: 'set' }).c('query', { xmlns: Strophe.NS.MAM, queryid });\n\nvar node = new Strophe.RSM(options);\n\nstanza.cnode(node.toXML());\n\nconnection.addHandler((message: any) =\u003e {\n  var fin = getElementByTagName(message, 'fin', Strophe.NS.MAM);\n  var result = getElementByTagName(message, 'result', Strophe.NS.MAM);\n\n  if (fin \u0026\u0026 queryid === fin.getAttribute('queryid')) {\n    var paging = new Strophe.RSM({ xml: fin });\n\n    // `paging` is now our paged RSM object with the following attributes:\n    //    paging.next()\n    //    paging.previous()\n    //    paging.toXML()\n    //    paging.fromXMLElement()\n\n    return false;\n  } else if (result \u0026\u0026 queryid === result.getAttribute('queryid')) {\n    messages.push(message);\n  }\n\n  return true;\n}, Strophe.NS.MAM);\n\nconnection.sendIQ(stanza, null, null);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrophe%2Fstrophejs-plugin-rsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrophe%2Fstrophejs-plugin-rsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrophe%2Fstrophejs-plugin-rsm/lists"}