Working with Smack 4.3.0 in a Multi User Chat (XEP-0045-1.21) I'm trying to find out if a room is already created or not, but I'm not sure if what I'm doing is the correct way.
I have search for it and the most relative answer to it was does MUC exist?.
Technically speaking:
- Rooms are created as public and members-only by default in OpenFire 4.2.0.
- All room's names are an id defined by the members name in a hash string i.e.
XXXXXX029d8c36b62259d0eXXXXXXXX
. This means that user A can create a room with B, C and get agroupId
like the previous one, but then user B (in another device) can try to create same room (with users A,B,C), which is going to give him samegroupId
. - Exist a architecture layer like whatsapp, so users can leave a
Group Chat
and rejoin whenever they want.
What I'm doing at this moment:
@WorkerThread
public boolean isGroupChatAlreadyCreated(@NonNull final String groupId)
throws
XmppStringprepException,
XMPPException.XMPPErrorException,
MultiUserChatException.NotAMucServiceException,
SmackException.NotConnectedException,
InterruptedException,
SmackException.NoResponseException {
List<HostedRoom> hostedRooms = manager.getHostedRooms(JidCreate.domainBareFrom(serviceDomain));
for (HostedRoom hostedRoom : hostedRooms) {
if (hostedRoom.getName().equalsIgnoreCase(groupId)) {
return true;
}
}
return false;
}
where manager
is MultiUserChatManager manager
and serviceDomain
is just a String
.
so, the questions: is this right way to do it? can it be improved?