मैं नोड js और xmppNodeJS xmpp सर्वर
में पहला कदम बनाने मैं
यहाँ संदेश भेजने के लिए नोड js पर xmpp सर्वर पर चलाने की आवश्यकता प्रक्रिया है: मैं नोड xmpp सर्वर का उपयोग https://github.com/astro/node-xmpp एक सर्वर (/examples/c2s.js) का उदाहरण चलाएं दो क्लाइंट्स के साथ सर्वर में शामिल हों (क्लाइंट अन्य सर्वर जेबबर पर परीक्षण किया जाता है - यह काम करता है और संदेश भेज रहे हैं)
ग्राहकों के पास मेरे सर्वर पर प्राधिकरण है। लेकिन जब मैं एक से दूसरे ग्राहक से एक संदेश भेजने, संदेश (मैं लॉग में यह देखें) सर्वर से आता है और कि प्राप्तकर्ता को नहीं आती संदेश था
मैं `डॉन पता नहीं जहां देखने के लिए समस्या के लिए सर्वर कॉन्फ़िगरेशन? रूटिंग? खुद को जोड़ने के लिए संदेश आवश्यक हो सकता है?
मुझे plz मदद
अपने सर्वर कोड (उदाहरण के द्वारा)
var xmpp = require('../lib/node-xmpp');
var c2s = new xmpp.C2SServer({
port: 5222,
domain: 'localhost'
});
// On Connect event. When a client connects.
c2s.on("connect", function(client) {
c2s.on("register", function(opts, cb) {
console.log("REGISTER");
cb(true);
});
client.on("authenticate", function(opts, cb) {
console.log("AUTH" + opts.jid + " -> " +opts.password);
cb(null);
});
client.on("online", function() {
console.log("ONLINE");
client.send(new xmpp.Message({ type: 'chat' }).c('body').t("Hello there, little client."));
});
client.on("stanza", function(stanza) {
console.log("STANZA" + stanza);
});
client.on("disconnect", function(client) {
console.log("DISCONNECT");
});
});
मैं एक सर्वर चलाने के लिए और इस कोड को
var xmpp = require('../lib/node-xmpp');
var argv = process.argv;
if (argv.length < 6) {
console.error('Usage: node send_message.js <my-jid> <my-password> <my-text> <jid1> [jid2] ... [jidN]');
process.exit(1);
}
var cl = new xmpp.Client({ jid: argv[2], password: argv[3] });
cl.addListener('online',
function() {argv.slice(5).forEach(
function(to) {cl.send(new xmpp.Element('message', { to: to,type: 'chat'}).c('body').t(argv[4]));
});
// nodejs has nothing left to do and will exit
// cl.end();
});
cl.addListener('stanza',
function(stanza) {
if (stanza.is('message') &&
// Important: never reply to errors!
stanza.attrs.type !== 'error') {
console.log("New message");
// Swap addresses...
stanza.attrs.to = stanza.attrs.from;
delete stanza.attrs.from;
// and send back.
cl.send(stanza);
}
});
cl.addListener('error',
function(e) {
console.error(e);
process.exit(1);
});
कृपया समस्याग्रस्त कोड पोस्ट करें, अन्यथा हमारे पास कोई जानकारी नहीं है और केवल अनुमान लगाया जाएगा! – MattJ
आप भेजने से पहले से बदल रहे हैं? – Robert