xmpp-bosh-client
xmpp-bosh-client copied to clipboard
Stanza building example for <body> element
Hi,
I would try to generate a <body>
element with an inner value as reported in this example: https://github.com/kdcro101/xmpp-bosh-client#stanza-building
Probably I've missed something, but I don't understand how to get the output described in the example from the source.
I want to achieve this stanza output:
<iq type='set' id='juliet1'>
<query xmlns='urn:xmpp:mam:2'>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>urn:xmpp:mam:2</value>
</field>
<field var='with'>
<value>[email protected]</value>
</field>
</x>
</query>
</iq>
I've made this, but it does not produce the inner value for <value>
element:
const root = $iq({ type: 'set', id: INTERNAL_HISTORICAL_ID });
const query = root.cnode($build('query', {
xmlns: 'urn:xmpp:mam:2',
}));
const x = query.cnode($build('x', {
xmlns: 'jabber:x:data',
type: 'submit',
}));
const fieldForm = x.cnode($build('field', {
var: 'FORM_TYPE',
type: 'hidden',
}));
fieldForm.cnode($build('value', {}, 'urn:xmpp:mam:2'));
const fieldWith = x.cnode($build('field', {
var: 'with'
}));
fieldWith.cnode($build('value', {}, jid));
Someone could help me?
Best regards