/** * Returns the XMPP connection. * * @return the XMPP connection */ protected XMPPConnection getConnection() { return connection(); }
/** * Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream is * not accepted. * * @param request IQ stanza that should be answered with a not-acceptable error * @throws NotConnectedException * @throws InterruptedException */ protected void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException { IQ error = IQ.createErrorResponse(request, StanzaError.Condition.not_acceptable); connection().sendStanza(error); }
/** * Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream open * request is rejected because its block size is greater than the maximum allowed block size. * * @param request IQ stanza that should be answered with a resource-constraint error * @throws NotConnectedException * @throws InterruptedException */ protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException, InterruptedException { IQ error = IQ.createErrorResponse(request, StanzaError.Condition.resource_constraint); connection().sendStanza(error); }
/** * Responses to the given IQ packet's sender with an XMPP error that an In-Band Bytestream * session could not be found. * * @param request IQ stanza that should be answered with a item-not-found error * @throws NotConnectedException * @throws InterruptedException */ protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException { IQ error = IQ.createErrorResponse(request, StanzaError.Condition.item_not_found); connection().sendStanza(error); }
/** * Disables the InBandBytestreamManager by removing its stanza listeners and resetting its * internal status, which includes removing this instance from the managers map. */ private void disableService() { final XMPPConnection connection = connection(); // remove manager from static managers map managers.remove(connection); // remove all listeners registered by this manager connection.unregisterIQRequestHandler(initiationListener); connection.unregisterIQRequestHandler(dataListener); connection.unregisterIQRequestHandler(closeListener); // shutdown threads this.initiationListener.shutdown(); // reset internal status this.userListeners.clear(); this.allRequestListeners.clear(); this.sessions.clear(); this.ignoredBytestreamRequests.clear(); }
/** * Establishes an In-Band Bytestream with the given user using the given session ID and returns * the session to send/receive data to/from the user. * * @param targetJID the JID of the user an In-Band Bytestream should be established * @param sessionID the session ID for the In-Band Bytestream request * @return the session to send/receive data to/from the user * @throws XMPPErrorException if the user doesn't support or accept in-band bytestreams, or if the * user prefers smaller block sizes * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ @Override public InBandBytestreamSession establishSession(Jid targetJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza); byteStreamRequest.setTo(targetJID); final XMPPConnection connection = connection(); // sending packet will throw exception on timeout or error reply connection.createStanzaCollectorAndSend(byteStreamRequest).nextResultOrThrow(); InBandBytestreamSession inBandBytestreamSession = new InBandBytestreamSession( connection, byteStreamRequest, targetJID); this.sessions.put(sessionID, inBandBytestreamSession); return inBandBytestreamSession; }