I am choosing an XMPP server and am currently trying NodeXMPP. I installed the full NodeXMPP (kernel, server, client, component, dependencies ...).
What struck me was that I had to do everything I needed to do to get customers to talk to each other, etc. Other XMPP servers (tigase ejabberd ...) do this from scratch.
My tiny instance: I create a server and store clients in an array, and then look for a client when another tries to say:
var xmpp = require('../index')
var c2s = new xmpp.C2SServer({
port: 5222,
domain: 'localhost'
})
var clients = new Array();
c2s.on('connect', function(client) {
client.on('authenticate', function(opts, cb) {
console.log('AUTH' + opts.jid + ' -> ' +opts.password)
clients.push(client);
})
client.on('stanza', function(stanza) {
if (stanza.is('message') && (stanza.attrs.type !== 'error')) {
var interlocuteur = getClient(stanza.attrs.to)
if (interlocuteur)
interlocuteur.send(stanza)
}
})
client.on('disconnect', function() {
console.log('DISCONNECT')
})
client.on('online', function() {
console.log('ONLINE')
client.send(new xmpp.Message({ type: 'chat' }).c('body').t('Hello there, little client.'))
})
})
And my question is: do I really need to independently determine these basic operations? If so, what is the point of Node -XMPP? Maybe it is to use NodeJS on another XMPP server, such as prosody?
source
share