2011-08-11 7 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); 
}); 
을 전송하는 방법을 알고
관련 문제