سؤال

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?

هل كانت مفيدة؟

المحلول

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"}))

نصائح أخرى

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
        });
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top