sstrigler/JSJaC

How to implement XEP-0163 PEP function in jsjac?

Closed this issue · 6 comments

Hi,
I have a remote device that has a PEP service(e.g. node is http://abc), and want jsjac client cloud listen this node and receive the event. How I do in jajac to add feature " http://abc+notify"?
Thanks.

When sending your initial presence you do

var p = new Presence();
var sha1_ver = ver_string(); // see https://xmpp.org/extensions/xep-0115.html for details
p.appendNode('c', {'xmlns': 'http://jabber.org/protocol/caps', 'node': 'jsjac', 'hash': 'sha1', 'ver': sha1_ver});
con.send(p);

You also need to register a handle for incoming messages before sending your presence:

con.registerHandler('message', 'event', 'http://jabber.org/protocol/pubsub#event', handlePepMessage);

Hi Sstrigler,
appreciate for your help. And I tried it , but it didn't work.Here is my codes, I have no idea it. Is the identify info error?

con.registerHandler('message', 'event', 'http://jabber.org/protocol/pubsub#event', handlePepMessage);

When connection is OK:

var presence = new JSJaCPresence();
var S = b64_sha1('/client/pc/a/test<http://mytset.com/protocol/fortest<http://mytset.com/protocol/fortest+notify<');
presence.appendNode('c', {'xmlns': 'http://jabber.org/protocol/caps', 'node': 'jsjac', 'hash': 'sha1', 'ver': S});
con.send(presence);

Can you be a bit more specific about what exactly didn't work? Does creating and sending the presence work? What does the raw xml look like? Or are you just not receiving any PEP event messages?
I'm not familiar with Entity Capabilities myself, so might very well be that the problem lies in creating that ver string.
Which server implementation are you using? Maybe try asking in their forum as well about how to create that string so that PEP works.

Also make sure you have that service’s his in your roster and that it’s subscribed to your presence.

s/his/jid

Hi, sstrigler,
I have fixed it. Firstly, the xmlns is not added to 'c' tag by below codes.I add it by hand.
presence.appendNode('c', {'xmlns': 'http://jabber.org/protocol/caps', 'node': 'jsjac', 'hash': 'sha1', 'ver': S});
Then I add the function that handles the disco info iq. Just like that:

      `  var payloads = new Array();`
        `payloads.push(iq.buildNode("identity",{'category': 'client', 'name': 'jsjac', 'type': 'pc'}));`
        `payloads.push(iq.buildNode("feature",{'var': 'xxxxx'}));`
        `var reply = iq.reply(payloads);`
         `con.send(reply);`

So thanks for your warm help.