Here is a simple xmpp component that echos every message using the xmppjs module
var jid = "echo", password = "your_password";
var xmpp = require("../xmpp");
var conn = new xmpp.Connection("your_domain");
var sys = require("sys");
var id = 1; conn.log = function (_, m) { sys.puts(m); }; conn.connect(jid, password, function (status, condition) {
if(status == xmpp.Status.CONNECTED)
{
conn.addHandler(onMessage, null, 'message', null, null, null); setInterval(function()
{
id++; conn.send(xmpp.iq({from: jid + "." + conn.host, to: conn.host, id: "iq:" + id, type: "get"}).c("ping", {xmlns: 'urn:xmpp:ping'})); }, 60000);
} else
conn.log(xmpp.LogLevel.DEBUG, "New connection status: " + status + (condition?(" ("+condition+")"):""));
}); function onMessage(message) {
conn.send(xmpp.message({
to:message.getAttribute("from"),
from:message.getAttribute("to"),
type: "chat"})
.c("body").t(message.getChild("body").getText()));
}
Create two new properties below and unzip the attached file into /opt/openfire/nodejs or wherever your OPENFIRE_HOME folder is.
property name
property value
js.xmppjs.echo.path
/opt/openfire/nodejs/xmppjs
js.xmppjs.echo
examples/echo.js