diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java index a673fd553..eebe26b34 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleContent.java @@ -266,9 +266,9 @@ public class JingleContent implements JingleTransportCallback { throws SmackException.NotConnectedException, InterruptedException { //Establish transport if (isReceiving()) { - getTransport().establishIncomingBytestreamSession(connection, this); + getTransport().establishIncomingBytestreamSession(connection, this, getParent()); } else if (isSending()) { - getTransport().establishOutgoingBytestreamSession(connection, this); + getTransport().establishOutgoingBytestreamSession(connection, this, getParent()); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java index 2b6169f47..72ba4ae6d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/components/JingleTransport.java @@ -76,10 +76,10 @@ public abstract class JingleTransport e public abstract String getNamespace(); - public abstract void establishIncomingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback) + public abstract void establishIncomingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session) throws SmackException.NotConnectedException, InterruptedException; - public abstract void establishOutgoingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback) + public abstract void establishOutgoingBytestreamSession(XMPPConnection connection, JingleTransportCallback callback, JingleSession session) throws SmackException.NotConnectedException, InterruptedException; public void setPeersProposal(JingleTransport peersProposal) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransport.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransport.java index 5aec90b67..90655de89 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransport.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transport/jingle_ibb/JingleIBBTransport.java @@ -72,9 +72,7 @@ public class JingleIBBTransport extends JingleTransport= 0) { + System.arraycopy(buf, 0, recv, read, r); + read += r; + } else { + break; + } + } + + LOGGER.log(Level.INFO, "Success!"); + + bytestreamSession.getInputStream().close(); + recvPoint.signal(); + } catch (IOException e) { + fail(e.toString()); + } + } + }); + } + + @Override + public void onTransportFailed(Exception e) { + LOGGER.log(Level.SEVERE, e.toString()); + recvPoint.signal(); + } + }, receiverSession); + + sender.establishOutgoingBytestreamSession(conTwo, new JingleTransportCallback() { + @Override + public void onTransportReady(final BytestreamSession bytestreamSession) { + LOGGER.log(Level.INFO, "Sending!"); + Async.go(new Runnable() { + @Override + public void run() { + try { + OutputStream outputStream = bytestreamSession.getOutputStream(); + outputStream.write(data); + outputStream.flush(); + + } catch (IOException e) { + fail(e.toString()); + } + } + }); + } + + @Override + public void onTransportFailed(Exception e) { + LOGGER.log(Level.SEVERE, e.toString()); + } + }, senderSession); + + recvPoint.waitForResult(60 * 1000); + Assert.assertArrayEquals(data, recv); + } +}