开发者

strophe.js PEP handler not attaching properly

开发者 https://www.devze.com 2023-03-20 16:43 出处:网络
I have been using a PEP plugin (found here: https://github.com/flosse/strophejs-plugins/blob/master/pep/strophe.pep.js) to connect to a users node however I am having some trouble. When my connected b

I have been using a PEP plugin (found here: https://github.com/flosse/strophejs-plugins/blob/master/pep/strophe.pep.js) to connect to a users node however I am having some trouble. When my connected block is called I do the following:

XMPP.connection.send($pres());
XMPP.getRoster();
XMPP.connection.addHandler(XMPP.getPresence, null, "presence");

When I receive a subscribed back from the JID of the node I am attempting to access (thus having bidirectional subscription) I execute:

XMPP.connection.pep.subscribe(JID, node,
function(){console.log("SUCCESS: Successfully subscribed to " + JID + "'s node " + node);},
function(){console.log开发者_运维问答("FAILURE: Unsuccessfully subscribed to " + JID + "'s node " + node);},
XMPP.onMessage,
true);

Where the JID and node are both valid. I receive the SUCCESS in the console however the event handler onMessage is not attached properly. I have debugging set so I can see incoming and outgoing stanzas and I do not receive anything from the node (which I know is being posted on a regular interval). I am not quite sure why this is happening.

If I remove everything from the connected block and simply manually create bidirectional subscription from the web console and add the XMPP.connection.pep.subscribe in that now empty block it works fine.

I have tried multiple PEP and pubsub plugins and get the same behavior. I'm at a road block and would greatly appreciate anyones input! Thanks!


Which server are you using?

It looks like you're trying to do an explicit subscription rather than the more normal implicit PEP subscription. Many servers will only support implicit subscription, where you add [node URI]+notify to your caps information.

Also, some servers have had a bug where you need to explicitly send presence to people who just subscribed to you, rather than the server correctly giving them your current presence when you approve their subscription request. This bug would impede implicit subscriptions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号