Node-XMPP是无用的吗? selectXMPP服务器

我select了XMPP服务器,并且正在尝试使用NodeXMPP。 我安装了完整的NodeXMPP(核心,服务器,客户端,组件,依赖…)。

令我吃惊的是,我必须做所有的后端工作:让客户彼此交stream。其他XMPP服务器(Tigase ejabberd …)从零开始做这些事情。

我的小实例:我创build一个服务器并将客户端存储在一个数组中,然后在另一个客户端尝试说话时search客户端:

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.')) }) }) 

还有我的问题:我真的需要自己编写这些基本的操作吗? 如果是这样,Node-XMPP有什么意义? 也许是通过其他XMPP服务器(如韵律)使用NodeJS?

node-xmpp是“只是”组件库,允许您构build自己的XMPP客户端,组件或甚至服务器。

作为一个图书馆,它并不能为特定的用例提供一个完整的解决scheme,而是一套允许构build一个的构build块。

如果您正在一个完整的已经制造的盒装XMPP服务器解决scheme的市场中,那么安装Prosody就是一个不错的select。 :^)

Apache Vysper XMPP Java服务器实现为您提供了更多已经实现的function,并且可以灵活地扩展/定制服务器。

https://github.com/tumakha/xmpp-light – 基于Apache Vysper的例子