/** * Creates a chat service for the specified service address. * * @param chatService The chat service address. Usually this is hosted at the subdomain "conference". * @return The chat service. */ public ChatService createChatService(Jid chatService) { return new ChatService(chatService, null, xmppSession, serviceDiscoveryManager, this); }
@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; } }
@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; } }
final ChatRoom room = chatService.createRoom(generateConversationsLikePronounceableName()); room.enter("test").getResult(); boolean hasFormField = false;
/** * Discovers the multi-user chat services hosted at the connected domain. * * @return The async result with the list of chat services. * @see <a href="https://xmpp.org/extensions/xep-0045.html#disco-service">6.1 Discovering a MUC Service</a> */ public AsyncResult<List<ChatService>> discoverChatServices() { return serviceDiscoveryManager.discoverServices(Identity.conferenceText()).thenApply(services -> services.stream() .map(service -> new ChatService(service.getJid(), service.getName(), xmppSession, serviceDiscoveryManager, this)) .collect(Collectors.toList())); }