/** * Returns the next available message in the chat. The method call will * block (not return) until a message is available. * * @return the next message. * @throws InterruptedException */ public Message nextMessage() throws InterruptedException { return messageCollector.nextResult(); }
message = messageCollector.nextResult(); if (message != null) { messages.add(message);
/** * Returns the next available message in the chat. * * @param timeout * the maximum amount of time to wait for the next message. * @return the next message, or null if the timeout elapses without a * message becoming available. * @throws InterruptedException */ public Message nextMessage(long timeout) throws InterruptedException { return messageCollector.nextResult(timeout); }
when(collector.nextResult(anyInt())).thenAnswer(answer); when(collector.nextResult()).thenAnswer(answer); Answer<Stanza> answerOrThrow = new Answer<Stanza>() { @Override
/** * Returns the next available packet. The method call will block until the connection's default * timeout has elapsed. * * @param <P> type of the result stanza. * @return the next available packet. * @throws InterruptedException */ public <P extends Stanza> P nextResult() throws InterruptedException { return nextResult(connection.getReplyTimeout()); }
connection.createStanzaCollectorAndSend(iotDataRequest).nextResultOrThrow(); doneCollector.nextResult();
/** * Returns the next available message in the chat. The method call will block * (not return) until a message is available. * * @return the next message. * @throws MucNotJoinedException * @throws InterruptedException */ public Message nextMessage() throws MucNotJoinedException, InterruptedException { if (messageCollector == null) { throw new MucNotJoinedException(this); } return messageCollector.nextResult(); }
/** * Returns the next available message in the chat. The method call will block * (not return) until a stanza is available or the <tt>timeout</tt> has elapased. * If the timeout elapses without a result, <tt>null</tt> will be returned. * * @param timeout the maximum amount of time to wait for the next message. * @return the next message, or <tt>null</tt> if the timeout elapses without a * message becoming available. * @throws MucNotJoinedException * @throws InterruptedException */ public Message nextMessage(long timeout) throws MucNotJoinedException, InterruptedException { if (messageCollector == null) { throw new MucNotJoinedException(this); } return messageCollector.nextResult(timeout); }
public IQ sendSessionAccept(FullJid recipient, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContent.Senders contentSenders, JingleContentDescription description, JingleContentTransport transport) throws SmackException.NotConnectedException, InterruptedException { Jingle jingle = createSessionAccept(recipient, sessionId, contentCreator, contentName, contentSenders, description, transport); return connection.createStanzaCollectorAndSend(jingle).nextResult(); }
public IQ sendSessionInitiate(FullJid recipient, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContent.Senders contentSenders, JingleContentDescription description, JingleContentTransport transport) throws SmackException.NotConnectedException, InterruptedException { Jingle jingle = createSessionInitiate(recipient, sessionId, contentCreator, contentName, contentSenders, description, transport); return connection.createStanzaCollectorAndSend(jingle).nextResult(); }
private static void assertMessageWithBodyReceived(String body, StanzaCollector collector) throws InterruptedException { Message message = collector.nextResult(); assertNotNull(message); assertEquals(body, message.getBody()); } }
RTPBridge response = collector.nextResult();
/** * Retrieves the AgentChatHistory associated with a particular agent jid. * * @param jid the jid of the agent. * @param maxSessions the max number of sessions to retrieve. * @param startDate point in time from which on history should get retrieved. * @return the chat history associated with a given jid. * @throws XMPPException if an error occurs while retrieving the AgentChatHistory. * @throws NotConnectedException * @throws InterruptedException */ public AgentChatHistory getAgentHistory(EntityBareJid jid, int maxSessions, Date startDate) throws XMPPException, NotConnectedException, InterruptedException { AgentChatHistory request; if (startDate != null) { request = new AgentChatHistory(jid, maxSessions, startDate); } else { request = new AgentChatHistory(jid, maxSessions); } request.setType(IQ.Type.get); request.setTo(workgroupJID); AgentChatHistory response = connection.createStanzaCollectorAndSend( request).nextResult(); return response; }
/** * Query for metadata associated with a session id. * * @param sessionID the sessionID to query for. * @return Map a map of all metadata associated with the sessionID. * @throws XMPPException if an error occurs while getting information from the server. * @throws NotConnectedException * @throws InterruptedException */ public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException, NotConnectedException, InterruptedException { ChatMetadata request = new ChatMetadata(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setSessionID(sessionID); ChatMetadata response = connection.createStanzaCollectorAndSend(request).nextResult(); return response.getMetadata(); }
/** * Get a new STUN Server Address and port from the server. * If a error occurs or the server don't support STUN Service, null is returned. * * @param connection * @return the STUN server address * @throws NotConnectedException * @throws InterruptedException */ @SuppressWarnings("deprecation") public static STUN getSTUNServer(XMPPConnection connection) throws NotConnectedException, InterruptedException { if (!connection.isConnected()) { return null; } STUN stunPacket = new STUN(); stunPacket.setTo(DOMAIN + "." + connection.getXMPPServiceDomain()); StanzaCollector collector = connection.createStanzaCollectorAndSend(stunPacket); STUN response = collector.nextResult(); // Cancel the collector. collector.cancel(); return response; }
/** * Get a new RTPBridge Candidate from the server. * If a error occurs or the server don't support RTPBridge Service, null is returned. * * @param connection * @param sessionID * @return the new RTPBridge * @throws NotConnectedException * @throws InterruptedException */ @SuppressWarnings("deprecation") public static RTPBridge getRTPBridge(XMPPConnection connection, String sessionID) throws NotConnectedException, InterruptedException { if (!connection.isConnected()) { return null; } RTPBridge rtpPacket = new RTPBridge(sessionID); rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain()); StanzaCollector collector = connection.createStanzaCollectorAndSend(rtpPacket); RTPBridge response = collector.nextResult(); // Cancel the collector. collector.cancel(); return response; }
P result; try { result = nextResult(timeout); } finally { cancel();
/** * Check if the server support RTPBridge Service. * * @param connection * @return the RTPBridge * @throws NotConnectedException * @throws InterruptedException */ @SuppressWarnings("deprecation") public static RTPBridge relaySession(XMPPConnection connection, String sessionID, String pass, TransportCandidate proxyCandidate, TransportCandidate localCandidate) throws NotConnectedException, InterruptedException { if (!connection.isConnected()) { return null; } RTPBridge rtpPacket = new RTPBridge(sessionID, RTPBridge.BridgeAction.change); rtpPacket.setTo(RTPBridge.NAME + "." + connection.getXMPPServiceDomain()); rtpPacket.setType(Type.set); rtpPacket.setPass(pass); rtpPacket.setPortA(localCandidate.getPort()); rtpPacket.setPortB(proxyCandidate.getPort()); rtpPacket.setHostA(localCandidate.getIp()); rtpPacket.setHostB(proxyCandidate.getIp()); // LOGGER.debug("Relayed to: " + candidate.getIp() + ":" + candidate.getPort()); StanzaCollector collector = connection.createStanzaCollectorAndSend(rtpPacket); RTPBridge response = collector.nextResult(); // Cancel the collector. collector.cancel(); return response; }
Message msg2 = collector.nextResult(2000); assertNotNull("No message was received", msg2); assertEquals("Subjects are different", msg.getSubject(), msg2.getSubject());
Message msg2 = collector2.nextResult(); assertNotNull("Message not found", msg2); Message msg3 = collector.nextResult(); assertNotNull("Message not found", msg3);