0

Is there any predefined method in XMPP to get the number of rooms already present on the openfire server. I have made a thorough search but I am unable to get the good and working answer.

Please let me know how can I get the rooms available on openfire server ( already created ).

The code

boolean supports = MultiUserChat.isServiceEnabled(conn, "user3@host.org/Smack");

is returning a NUll pointer.

Flow
  • 23,572
  • 15
  • 99
  • 156
Gaurav Arora
  • 8,282
  • 21
  • 88
  • 143

1 Answers1

2

You can use getHostedRooms method of MultiUserChat class of Smack API.

public static Collection<HostedRoom> getHostedRooms(Connection connection, String serviceName) throws XMPPException

This will return collection of all public rooms on server. And before this check if user supports MUC or not by

boolean supports = MultiUserChat.isServiceEnabled(conn, "user3@host.org/Smack");

More information on this can be found on smack api guide.

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
  • Thanks for the reply bro. I am checking it and will let you know if it works. Meanwhile can you please help me in this matter? http://stackoverflow.com/questions/13028384/xmpp-room-invitation – Gaurav Arora Oct 26 '12 at 07:16
  • I am getting a nullpointer exception on isServiceEnabled line? – Gaurav Arora Oct 26 '12 at 07:26
  • @GauravArora instead of "user3@host.org/Smack" you have to pass your user id. Also make sure your connection is not null. Call this after login is successful. – Harry Joy Oct 26 '12 at 10:00
  • Its obvious dear I am doing it with my own id bro :( – Gaurav Arora Oct 26 '12 at 10:20
  • Then most possible cause is that your connection object is null. Check for it. – Harry Joy Oct 26 '12 at 10:58
  • debugger is not responding on that line. I have checked the connection. It is working fine at that place. Moreover while debugging it says : -supports cannot be resolved to a variable.Dats it. – Gaurav Arora Oct 26 '12 at 11:12
  • if you are sure your server has rooms then you can skip that line and directly try to get the rooms. – Harry Joy Oct 27 '12 at 06:43