Question

I am building an XMPP chat application using strophe.js (javascript) and openfire as server.

The application is working fine; however, I cannot manage to display the name attribute for the Rosters gathered. Either the name is undifined or it displays the jid of the Roster.

Where is the name stored in the XMPP database and how could I change it? Should I add the name in the memeber table where all xmpp users are store?

Était-ce utile?

La solution

Here it is in Javascript:

var iq = $iq({type: 'set'}).c('query', {xmlns: 'jabber:iq:roster'}).c("item",  {jid:'romeo@example.net',name:'MyRomeo'});
con.sendIQ(iq);

con.send($pres({to: 'test@test.com', type: "subscribe"}))

Autres conseils

You can set your contact's name using strophe.js. Just send this query:

<iq from='juliet@example.com/balcony'
       id='gb3sv487'
       type='set'>
     <query xmlns='jabber:iq:roster'>
       <item jid='romeo@example.net'
             name='MyRomeo'/>
     </query>
   </iq>

Strophe.js:

var query = $iq({type: 'set'}).c('query', {xmlns: 'jabber:iq:roster'}).c('item', jid: 'jid@domain.com', name: 'JoeDoe')     
        connection.sendIQ(query, function success(response) {
            console.log(response); // for debugging purposes
        });
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top