javascriptxmppstropheconverse.js

How can I get the online users list using converse Strophe environment in react js


Is there any method to get the online user list using converse js? I found it is possible by Strophe.js which is already implemented on converse.js.

I created a converse plugin but don't know how can I show the online users.

export const moderationActions = () => {
  window.converse.plugins.add('moderation-actions', {
    dependencies: [],
    initialize: function () {
      const _converse = this._converse;
      const Strophe = window.converse.env.Strophe;
      console.log(Strophe, 'Strophe');
    },
  });
};

Solution

  • You can try the following:

    await api.waitUntil('rosterContactsFetched');
    const online_contacts = _converse.roster.models.filter(m => m.presence.get('show') === "online");