conversejs / converse.js

Web-based XMPP/Jabber chat client written in JavaScript
http://conversejs.org
Mozilla Public License 2.0
3.08k stars 772 forks source link

onMessage listener not working for muclight room #2845

Closed Banu1412 closed 2 years ago

Banu1412 commented 2 years ago

Bug is onMessage listener not working for muclight room

Using the Below code to get instant messages from muclight rooms.

  _converse.api.listen.on('message', function (msg) { 
        console.log(msg);
  });

Expected behavior After connecting with the converse api I add the listener for getting the messages instantly. unfortunately It is not working for muclight room chat messages. Kindly give me a solution to overcome this issue.

Environment

jcbrand commented 2 years ago

The message event is only triggered for message stanzas that have been accepted and processed by Converse.

https://conversejs.org/docs/html/api/-_converse.html#event:message

For groupchats, this only happens once the chat has been opened and joined by the user. Converse won't process any groupchat messages for which there isn't a corresponding ChatRoom model (for example created via api.rooms.open).

Converse doesn't support MUC light, which is a non-standard protocol only supported by the MongooseIM server AFAIK.

Perhaps the existing MUC support of Converse could be extended or updated to also support MUC light, I don't know enough about MUC light to have an informed opinion of it.

In any case, you'd first have to add support for opening and joining a MUC light room before you could listen on message event for MUC light groupchat messages.

If you need more low-level access, and listen for any incoming XMPP stanza, you'll need to use Strophe's API.

For example addHandler: http://strophe.im/strophejs/doc/1.4.3/files/strophe-umd-js.html#Strophe.Connection.addHandler