Create Muc Group Like Whatsapp Android
I can creating and joining MUC rooms. But user disconnects from the Openfire server, he is removed from the group on the server side. How can i similar to what Whatsapp does, i.e.
Solution 1:
When inviting an user, you have to grant him Membership:
MultiUserChat muc = multiUserChatManager.getMultiUserChat("foo@conference.myserver");
muc.invite("jhondoe@myserver","Join this groupchat!");
then you can grant him voice and you must grantMembership (or Ownership or Moderation as you like/need):
muc.grantVoice("jhondoe@myserver");
muc.grantMembership("jhondoe@myserver");
finally you have to integrate a list like that with your client:
publicList<String> retriveAllAffialiateOfMuc(MultiUserChat muc) throws NoResponseException, XMPPErrorException, NotConnectedException
{
List<Affiliate> affiliatesMembers = new ArrayList<Affiliate>();
if (muc.getAdmins() != null)
{
affiliatesMembers.addAll( muc.getAdmins() );
}
if ( muc.getMembers() != null)
{
affiliatesMembers.addAll( muc.getMembers() );
}
if ( muc.getOwners() != null )
{
affiliatesMembers.addAll( muc.getOwners() );
}
if (affiliatesMembers.size() == 0)
{
System.out.println("Error: looking for a non existant room");
returnnew ArrayList<String>(0);
}
List<String> affiliateMembersNames = new ArrayList<String>(affiliatesMembers.size());
for (Affiliate affiliate : affiliatesMembers)
{
affiliateMembersNames.add(affiliate.getJid().toString());
}
return affiliateMembersNames;
}
So you'll have a list of all users affiliate to the room. You can use this list in some callback to make a list of "all members" like in WhatsApp.
Look at the end of this page: https://www.igniterealtime.org/builds/smack/dailybuilds/documentation/extensions/muc.html
(dont' forget to vote!)
Post a Comment for "Create Muc Group Like Whatsapp Android"