xmpp - roster.getEntities() always return null aSmack android -
i want make chat application using xmpp , asmack facing problem: unable users on server. first made connection logged , tried retrieve users empty collection.
public void connect() { final progressdialog dialog = progressdialog.show(this, "connecting...", "please wait...", false); thread t = new thread(new runnable() { @override public void run() { // create connection connectionconfiguration connconfig = new connectionconfiguration( host, port, service); xmppconnection connection = new xmppconnection(connconfig); try { connection.connect(); log.i("xmppchatdemoactivity", "connected " + connection.gethost()); } catch (xmppexception ex) { log.e("xmppchatdemoactivity", "failed connect " + connection.gethost()); log.e("xmppchatdemoactivity", ex.tostring()); setconnection(null); } try { // saslauthentication.supportsaslmechanism("plain", 0); connection.login(username, password); log.i("xmppchatdemoactivity", "logged in " + connection.getuser()); // set status available presence presence = new presence(presence.type.available); connection.sendpacket(presence); setconnection(connection); // here in roster null. collection<rosterentry> roster = connection.getroster() .getentries(); (rosterentry entry : roster) { log.d("xmppchatdemoactivity", "--------------------------------------"); log.d("xmppchatdemoactivity", "rosterentry " + entry); log.d("xmppchatdemoactivity", "user: " + entry.getuser()); log.d("xmppchatdemoactivity", "name: " + entry.getname()); log.d("xmppchatdemoactivity", "status: " + entry.getstatus()); log.d("xmppchatdemoactivity", "type: " + entry.gettype()); } } catch (xmppexception ex) { log.e("xmppchatdemoactivity", "failed log in " + username); log.e("xmppchatdemoactivity", ex.tostring()); setconnection(null); } dialog.dismiss(); } }); t.start(); dialog.show(); }
for getting rosters search plugin called registration properties or if pre installed search in users section.
then check enable automatically adding of new users group. in bottom create new default group when new user created automatically added default group.
after run same code users present on xmpp protocol based server.
Comments
Post a Comment