/** * Establishes an In-Band Bytestream with the given user and returns the session to send/receive * data to/from the user. * <p> * Use this method to establish In-Band Bytestreams to users accepting all incoming In-Band * Bytestream requests since this method doesn't provide a way to tell the user something about * the data to be sent. * <p> * To establish an In-Band Bytestream after negotiation the kind of data to be sent (e.g. file * transfer) use {@link #establishSession(Jid, String)}. * * @param targetJID the JID of the user an In-Band Bytestream should be established * @return the session to send/receive data to/from the user * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the * user prefers smaller block sizes * @throws SmackException if there was no response from the server. * @throws InterruptedException */ @Override public InBandBytestreamSession establishSession(Jid targetJID) throws XMPPException, SmackException, InterruptedException { String sessionID = getNextSessionID(); return establishSession(targetJID, sessionID); }
@Override public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }
@Override public void initiateOutgoingSession(JingleTransportInitiationCallback callback) { LOGGER.log(Level.INFO, "Initiate Jingle InBandBytestream session."); BytestreamSession session; try { session = InBandBytestreamManager.getByteStreamManager(jingleSession.getConnection()) .establishSession(jingleSession.getRemote(), theirProposal.getSessionId()); callback.onSessionInitiated(session); } catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException e) { callback.onException(e); } }
@Test public void shouldUseConfiguredStanzaType() throws SmackException, InterruptedException, XMPPException { InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection); byteStreamManager.setStanza(StanzaType.MESSAGE); protocol.addResponse(null, new Verification<Open, IQ>() { @Override public void verify(Open request, IQ response) { assertEquals(StanzaType.MESSAGE, request.getStanza()); } }); // start In-Band Bytestream byteStreamManager.establishSession(targetJID); protocol.verifyAll(); }
@Test public void shouldReturnSession() throws Exception { InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection); IQ success = IBBPacketUtils.createResultIQ(targetJID, initiatorJID); protocol.addResponse(success, Verification.correspondingSenderReceiver, Verification.requestTypeSET); // start In-Band Bytestream InBandBytestreamSession session = byteStreamManager.establishSession(targetJID); assertNotNull(session); assertNotNull(session.getInputStream()); assertNotNull(session.getOutputStream()); protocol.verifyAll(); }
/** * Invoking {@link InBandBytestreamManager#establishSession(org.jxmpp.jid.Jid)} should * throw an exception if the given target does not support in-band * bytestream. * @throws SmackException * @throws XMPPException * @throws InterruptedException */ @Test public void shouldFailIfTargetDoesNotSupportIBB() throws SmackException, XMPPException, InterruptedException { InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection); try { IQ errorIQ = IBBPacketUtils.createErrorIQ(targetJID, initiatorJID, StanzaError.Condition.feature_not_implemented); protocol.addResponse(errorIQ); // start In-Band Bytestream byteStreamManager.establishSession(targetJID); fail("exception should be thrown"); } catch (XMPPErrorException e) { assertEquals(StanzaError.Condition.feature_not_implemented, e.getStanzaError().getCondition()); } }
/** * Establishes an In-Band Bytestream with the given user and returns the session to send/receive * data to/from the user. * <p> * Use this method to establish In-Band Bytestreams to users accepting all incoming In-Band * Bytestream requests since this method doesn't provide a way to tell the user something about * the data to be sent. * <p> * To establish an In-Band Bytestream after negotiation the kind of data to be sent (e.g. file * transfer) use {@link #establishSession(String, String)}. * * @param targetJID the JID of the user an In-Band Bytestream should be established * @return the session to send/receive data to/from the user * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the * user prefers smaller block sizes */ public InBandBytestreamSession establishSession(String targetJID) throws XMPPException { String sessionID = getNextSessionID(); return establishSession(targetJID, sessionID); }
/** * Establishes an In-Band Bytestream with the given user and returns the session to send/receive * data to/from the user. * <p> * Use this method to establish In-Band Bytestreams to users accepting all incoming In-Band * Bytestream requests since this method doesn't provide a way to tell the user something about * the data to be sent. * <p> * To establish an In-Band Bytestream after negotiation the kind of data to be sent (e.g. file * transfer) use {@link #establishSession(String, String)}. * * @param targetJID the JID of the user an In-Band Bytestream should be established * @return the session to send/receive data to/from the user * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the * user prefers smaller block sizes */ public InBandBytestreamSession establishSession(String targetJID) throws XMPPException { String sessionID = getNextSessionID(); return establishSession(targetJID, sessionID); }
/** * Establishes an In-Band Bytestream with the given user and returns the session to send/receive * data to/from the user. * <p> * Use this method to establish In-Band Bytestreams to users accepting all incoming In-Band * Bytestream requests since this method doesn't provide a way to tell the user something about * the data to be sent. * <p> * To establish an In-Band Bytestream after negotiation the kind of data to be sent (e.g. file * transfer) use {@link #establishSession(String, String)}. * * @param targetJID the JID of the user an In-Band Bytestream should be established * @return the session to send/receive data to/from the user * @throws XMPPException if the user doesn't support or accept in-band bytestreams, or if the * user prefers smaller block sizes */ public InBandBytestreamSession establishSession(String targetJID) throws XMPPException { String sessionID = getNextSessionID(); return establishSession(targetJID, sessionID); }
public OutputStream createOutgoingStream(String streamID, String initiator, String target) throws XMPPException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }
public OutputStream createOutgoingStream(String streamID, String initiator, String target) throws XMPPException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }
public OutputStream createOutgoingStream(String streamID, String initiator, String target) throws XMPPException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }