2011-08-11 12 views
3

node-xmppを使用してクライアントからメッセージを受信する方法...?ejabberdクライアントからnode-xmppにメッセージを受信する方法

私はすでに

var net = require("net"); 
var xmpp = require('node-xmpp'); 

var server = net.createServer(
     function(socket) { 

       socket.setEncoding("utf8"); 
       socket.on('data',function(data) { 
         chat(data,socket); 
       }); 
     } 
); 
server.listen(3000); 

var chat = function(data,socket) { 
     var cl = new xmpp.Client({ jid: '[email protected]',password: '12345' }); 

     cl.on('online', 
       function() { 
          cl.send(new xmpp.Element('message', 
                { to: '[email protected]', 
                 type: 'chat'}). 
            c('body'). 
            t(data)); 


        // nodejs has nothing left to do and will exit 
        cl.end(); 
       }); 
} 

答えて

0
cl.addListener('stanza', function(stanza) { 
    connection.write(stanza.children[1].children); 
    console.log(stanza.children[1].children); 
}); 
...ここにメッセージを送信するためにどのようにサンプルコードをメッセージ

を送っする方法を知ら

関連する問題