/** * Sends a message to the chat room. * * @param text the text of the message to send. * @throws NotConnectedException * @throws InterruptedException */ public void sendMessage(String text) throws NotConnectedException, InterruptedException { Message message = createMessage(); message.setBody(text); connection.sendStanza(message); }
/** * Changes the subject within the room. As a default, only users with a role of "moderator" * are allowed to change the subject in a room. Although some rooms may be configured to * allow a mere participant or even a visitor to change the subject. * * @param subject the new room's subject to set. * @throws XMPPErrorException if someone without appropriate privileges attempts to change the * room subject will throw an error with code 403 (i.e. Forbidden) * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Message message = createMessage(); message.setSubject(subject); // Wait for an error or confirmation message back from the server. StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() { @Override public boolean accept(Stanza packet) { Message msg = (Message) packet; return subject.equals(msg.getSubject()); } }); StanzaCollector response = connection.createStanzaCollectorAndSend(responseFilter, message); // Wait up to a certain number of seconds for a reply. response.nextResultOrThrow(); }
@Override public void sendMessage(WikittyEvent event) throws Exception { if (propagateEvent) { Message message = muc.createMessage(); message.setBody(event.getType().toString()); message.setProperty(PROPERTY_EVENT_NAME, event); muc.sendMessage(message); } }