Question

Hi I am having problems on decline invite to chat room. This is my stanza:

var msg = $msg({"from" : tojid,"to" : room}).c("x", {"xmlns" : Strophe.NS.MUC_USER}).c("decline", {"to" : fromjid+"@188.2.16.19"});

msg.c("reason").t("Can talk right now.");
Chat.connection.send(msg.tree());

But that is not sent first time and invitation is not declined. It keeps returning all time. If I send that twice on sender end I have response:

<body xmlns='http://jabber.org/protocol/httpbind'><message xmlns="jabber:client" from="epthi_702@conference.188.2.16.19" to="nikola_degree361_com@188.2.16.19"><x xmlns="http://jabber.org/protocol/muc#user"><decline from="nikola_pregmatch_org@188.2.16.19"><reason>Can talk right now.</reason></decline></x></message></body>

Also I can not figure out handler for this. What to put in strophe addHandler? Fro group invite I have :

Chat.connection.addHandler(Chat.onInvite,"jabber:x:conference");
Was it helpful?

Solution

I added an "Action" attribute and returned it using the same namespace. My "onInvite" handler looks for the "action==='deny' and handles it accordingly.

connection().send($msg({ to: toJid, from: fromJid}).c('x', { xmlns: 'jabber:x:conference', jid: roomJid, action: 'deny' }).tree());

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top