How can I send custom messages with XMPP using the Strophe JS library?
I know that using $msg( ... );
I can create a chat message element and connection.send(m);
send it through XMPP connection.
I need a way to send messages not for chat but for "command" (or other purpose).
Using Strophe.js you can simply do:
function sendCustomMessage(to, from, body, field1, field2) {
var m = $msg({to: to, from: from, type: 'chat'}).c("body").t(body);
// custom data
m.up().c("data", {xmlns: 'my-custom-data-ns', field1: field1, field2: field2});
connection.send(m);
}