simple-xmpp / node-simple-xmpp

Simple High Level NodeJS XMPP Client
302 stars 90 forks source link

problems with Roster #69

Open jlveliz opened 8 years ago

jlveliz commented 8 years ago

i´m creating a chat, well.. on the first session i retrieve all roster's account, second i close this session and open other session and i retrieve all roster's first account. i'm working with sockets. simpleXMMP.connect({ jid: user, password: passs, host: HOST }) ;

io.sockets.on('connection', function(socket) { simpleXMMP.getRoster(); });

simpleXMMP.on('stanza', function(stanza) { if (stanza.id == 'roster_0') { //CONTACTS var rosters = []; stanza.children[0].children.forEach(function(element, index) { var roster = { jid: element.attrs.jid, name: element.attrs.name, subscription: element.attrs.subscription }; rosters.push(roster); }); io.sockets.on('connect', function(socket) { socket.emit('roster', rosters); }) } });