You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module.exports=function(client,stanzas){// 1. Create and register our custom `mystanza` stanza typevartypes=stanzas.utils;varFoo=stanzas.define({name: 'mystanza',element: 'foo',namespace: 'http://example.com/p/foo',fields: {type: types.attribute('type'),value: types.text()}});stanzas.withMessage(function(Message){stanzas.extend(Message,Foo);});// 2. Add API to the stanza.io client for sending `mystanza` dataclient.sendMyStanza=function(jid,foo){client.sendMessage({to: jid,mystanza: {type: 'bar',value: foo}});};// 3. Listen for incoming `mystanza` data and emit our own eventclient.on('message',function(msg){if(msg.mystanza){client.emit('foo',msg);}});};