/** * Destroys the room. * * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#destroyroom">10.9 Destroying a Room</a> */ public final AsyncResult<IQ> destroy() { return destroy(null); }
/** * Enters the room. * * @param nick The nickname. * @return The async result with the self-presence returned by the chat room. */ public AsyncResult<Presence> enter(String nick) { return enter(nick, null, null); }
/** * Creates a chat room for the specified room address. * * @param roomAddress The chat room address. * @return The chat room. */ public ChatRoom createChatRoom(Jid roomAddress) { return new ChatRoom(roomAddress, null, xmppSession, serviceDiscoveryManager, this); }
@Override public Result run() { final ServiceDiscoveryManager serviceDiscoveryManager = client.getManager(ServiceDiscoveryManager.class); final MultiUserChatManager multiUserChatManager = client.getManager(MultiUserChatManager.class); try { List<ChatService> chatServices = multiUserChatManager.discoverChatServices().getResult(); if (chatServices.size() < 1) { return Result.FAILED; } final ChatService chatService = chatServices.get(0); final ChatRoom room = chatService.createRoom(UUID.randomUUID().toString()); room.enter("test"); try { final DataForm.Field mam = room.getConfigurationForm().get().findField("mam"); if (mam != null) { return Result.PASSED; } } catch (ExecutionException | InterruptedException e) { //ignore } final Set<String> features = serviceDiscoveryManager.discoverInformation(room.getAddress()).getResult().getFeatures(); final boolean mam = TestUtils.hasAnyone(MAM.NAMESPACES,features); room.destroy().getResult(); return mam ? Result.PASSED : Result.FAILED; } catch (XmppException e) { return Result.FAILED; } }
@Override public boolean run() { final ServiceDiscoveryManager serviceDiscoveryManager = client.getManager(ServiceDiscoveryManager.class); final MultiUserChatManager multiUserChatManager = client.getManager(MultiUserChatManager.class); try { List<ChatService> chatServices = multiUserChatManager.discoverChatServices().getResult(); if (chatServices.size() < 1) { LOGGER.debug("Unable to find a MUC service"); return false; } final ChatService chatService = chatServices.get(0); final ChatRoom room = chatService.createRoom(generateConversationsLikePronounceableName()); room.enter("test").getResult(); final Set<String> features = serviceDiscoveryManager.discoverInformation(room.getAddress()).getResult().getFeatures(); room.destroy().getResult(); return features.contains(VCard.NAMESPACE); } catch (XmppException e) { LOGGER.debug(e.getMessage()); } return false; } }
void roomExited(ChatRoom chatRoom) { enteredRoomsMap.remove(chatRoom.getAddress()); }
/** * Revokes a user's membership. Note that you must be an owner or admin of the room. * * @param user The user. * @param reason The reason (optional). May be <code>null</code>. * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#revokemember">9.4 Revoking Membership</a> * @see #grantMembership(Jid, String, String) */ public final AsyncResult<IQ> revokeMembership(Jid user, String reason) { return changeAffiliation(Affiliation.NONE, user, reason); }
/** * Revokes voice from a participant. Note that you must be a moderator in the room. * * @param nickname The nickname. * @param reason The reason (optional). May be <code>null</code>. * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#revokevoice">8.4 Revoking Voice from a Participant</a> * @see #grantVoice(String, String) */ public final AsyncResult<IQ> revokeVoice(String nickname, String reason) { return changeRole(Role.VISITOR, nickname, reason); }
/** * Gets the admins of the room. * * @return The async result with the admins. * @see <a href="https://xmpp.org/extensions/xep-0045.html#modifymember">9.5 Modifying the Member List</a> */ public AsyncResult<List<Item>> getAdmins() { return getByAffiliation(Affiliation.ADMIN); }
/** * Exits the room. * * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#exit">7.14 Exiting a Room</a> */ public AsyncResult<Void> exit() { return exit(null); }
room.enter("test").getResult(); boolean hasFormField = false; try { DataForm form = room.getConfigurationForm().get(); final DataForm.Field mam = form.findField("mam"); //ejabberd community final DataForm.Field roomConfigMam = form.findField("muc#roomconfig_mam"); //ejabberd SaaS final Set<String> features = serviceDiscoveryManager.discoverInformation(room.getAddress()).getResult().getFeatures(); final boolean hasFeature = TestUtils.hasAnyone(MAM.NAMESPACES, features); room.destroy().getResult(); return (hasFeature || hasFormField); } catch (XmppException e) {
void roomEntered(ChatRoom chatRoom, String nick) { enteredRoomsMap.put(chatRoom.getAddress(), new Item(chatRoom.getAddress(), null, nick)); }
/** * Bans a user. Note that you must be an owner or admin of the room. * * @param user The user. * @param reason The reason (optional). May be <code>null</code>. * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#ban">9.1 Banning a User</a> */ public final AsyncResult<IQ> banUser(Jid user, String reason) { return changeAffiliation(Affiliation.OUTCAST, user, reason); }
/** * Grants moderator status to a participant or visitor. Note that you must be an admin in the room. * * @param nickname The nickname. * @param reason The reason (optional). May be <code>null</code>. * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#grantmod">9.6 Granting Moderator Status</a> */ public final AsyncResult<IQ> grantModeratorStatus(String nickname, String reason) { return changeRole(Role.MODERATOR, nickname, reason); }
/** * Gets the owners of the room. * * @return The async result with the owners. * @see <a href="https://xmpp.org/extensions/xep-0045.html#modifymember">9.5 Modifying the Member List</a> */ public AsyncResult<List<Item>> getOwners() { return getByAffiliation(Affiliation.OWNER); }
/** * Enters the room with a password. * * @param nick The nickname. * @param password The password. * @return The async result with the self-presence returned by the chat room. */ public AsyncResult<Presence> enter(String nick, String password) { return enter(nick, password, null); }
/** * Grants owner status to a user. Note that you must be an owner of the room. * * @param user The user. * @param reason The reason (optional). May be <code>null</code>. * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#grantowner">10.3 Granting Owner Status</a> * @see #revokeOwnerStatus(Jid, String) */ public final AsyncResult<IQ> grantOwnerStatus(Jid user, String reason) { return changeAffiliation(Affiliation.OWNER, user, reason); }
/** * Kicks an occupant from the room. Note that you must be a moderator in the room. * * @param nickname The nickname. * @param reason The reason (optional). May be <code>null</code>. * @return The async result. * @see <a href="https://xmpp.org/extensions/xep-0045.html#kick">8.2 Kicking an Occupant</a> */ public final AsyncResult<IQ> kickOccupant(String nickname, String reason) { return changeRole(Role.NONE, nickname, reason); }
/** * Gets the outcasts of the room. * * @return The async result with the outcasts. * @see <a href="https://xmpp.org/extensions/xep-0045.html#modifymember">9.5 Modifying the Member List</a> */ public AsyncResult<List<Item>> getOutcasts() { return getByAffiliation(Affiliation.OUTCAST); }
/** * Creates a new chat room. Note that this room is only created locally. * * @param room The room. This is the local part of the room address, e.g. room@service. * @return The chat room. */ public ChatRoom createRoom(String room) { return new ChatRoom(serviceAddress.withLocal(room), null, xmppSession, serviceDiscoveryManager, multiUserChatManager); }