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