Reputation: 186
I am using MUC for group chat using smack. i want to get list of MUC rooms which user already participated like whatsapp.
Using belove code, I get only rooms which user joined but i need to get the all groups which I already became a member.
Here is my code :
List<EntityBareJid> joinedRoomes = manager.getJoinedRooms(conn);
for (EntityBareJid jRoomName : joinedRoomes) {
Log.e("Group Chat : Joined room = " , jRoomName.toString());
}
Anyone help me?
Also i want to add avatar image for MUC group. how can i do that?
Upvotes: 0
Views: 905
Reputation: 812
You may try this way to get group members and detail
public static List<String> getRoomInfo(String grp_id) {
List<String> jids = new ArrayList<>();
try {
EntityBareJid mucJid = JidCreate.entityBareFrom(grp_id + "@" + Constants.GRP_SERVICE);
mucChatManager = MultiUserChatManager.getInstanceFor(MyApplication.connection);
mucChat = mucChatManager.getMultiUserChat(mucJid);
RoomInfo info = mucChatManager.getRoomInfo(mucJid);
LogM.e("Number of occupants:" + info.getOccupantsCount());
LogM.e("Room Subject:" + info.getSubject());
Log.e(TAG, "members " + mucChat.getMembers().size());
List<Affiliate> affiliatesMembers = mucChat.getMembers();
Log.e(TAG, "members1 " + affiliatesMembers.size());
for (Affiliate affiliate : affiliatesMembers) {
Log.e(TAG, "members: Jid:" + affiliate.getJid()
);
if (affiliate.getJid() != null) {
jids.add(affiliate.getJid().toString());
}
}
return jids;
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException | XmppStringprepException e) {
Log.e(TAG, "Group Error : " + e.getMessage());
} catch (SmackException.NotConnectedException e) {
Log.e(TAG, "Group Error2 : " + e.getMessage());
}
return jids;
}
Upvotes: 0
Reputation: 4120
There is no command to get the list of rooms where an account is member/admin/owner... There is only a command to get the list of affiliations of a specific room.
Also i want to add avatar image for MUC group. how can i do that?
A room does not have vcard, so it has no place to store the image. But it has a "Description" field, where you can put the URL of the avatar image, and then modify clients to read that URL and display the image as the room avatar.
Upvotes: 1