From a101de29fd2783ee2d8b4d022247a630f5bf2bc0 Mon Sep 17 00:00:00 2001 From: vanitasvitae Date: Sat, 24 Jun 2017 12:14:05 +0200 Subject: [PATCH] JIBB works --- .../IncomingJingleFileOffer.java | 41 +++++++++---------- .../OutgoingJingleFileOffer.java | 30 +++++++------- .../jingle_ibb/JingleIBBTransportSession.java | 4 +- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java index 4a9a19ed8..3bce33306 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/IncomingJingleFileOffer.java @@ -135,29 +135,28 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement return; } - queued.add(threadPool.submit(new Runnable() { + state = State.active; + + transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() { @Override - public void run() { - try { - state = State.active; - transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() { - @Override - public void onSessionInitiated(BytestreamSession bytestreamSession) { - receivingThread = new ReceiveTask(bytestreamSession, file, target); - queued.add(threadPool.submit(receivingThread)); - } - - @Override - public void onException(Exception e) { - - } - }); - jutil.sendSessionAccept(getInitiator(), sid, creator, name, JingleContent.Senders.initiator, file, transportSession.createTransport()); - } catch (SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException e) { - LOGGER.log(Level.SEVERE, "Could not send session-accept: " + e, e); - } + public void onSessionInitiated(BytestreamSession bytestreamSession) { + LOGGER.log(Level.INFO, "BEFORE THREAD START!"); + receivingThread = new ReceiveTask(bytestreamSession, file, target); + queued.add(threadPool.submit(receivingThread)); + LOGGER.log(Level.INFO,"AFTER THREAD START!"); } - })); + + @Override + public void onException(Exception e) { + + } + }); + + try { + jutil.sendSessionAccept(getInitiator(), sid, creator, name, JingleContent.Senders.initiator, file, transportSession.createTransport()); + } catch (SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | InterruptedException e) { + e.printStackTrace(); + } } @Override diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java index c0378b15b..c4459899c 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/OutgoingJingleFileOffer.java @@ -103,24 +103,22 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession { LOGGER.log(Level.INFO, "Session was accepted. Initiate Bytestream."); state = State.active; - queued.add(threadPool.submit(new Runnable() { - @Override - public void run() { - transportSession.initiateOutgoingSession(new JingleTransportInitiationCallback() { - @Override - public void onSessionInitiated(final BytestreamSession session) { - LOGGER.log(Level.INFO, "BytestreamSession initiated. Start transfer."); - sendingThread = new SendTask(session, source); - queued.add(threadPool.submit(sendingThread)); - } - @Override - public void onException(Exception e) { - LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e); - } - }); + transportSession.processJingle(sessionAccept); + + transportSession.initiateOutgoingSession(new JingleTransportInitiationCallback() { + @Override + public void onSessionInitiated(final BytestreamSession session) { + LOGGER.log(Level.INFO, "BytestreamSession initiated. Start transfer."); + sendingThread = new SendTask(session, source); + queued.add(threadPool.submit(sendingThread)); } - })); + + @Override + public void onException(Exception e) { + LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e); + } + }); return jutil.createAck(sessionAccept); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_ibb/JingleIBBTransportSession.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_ibb/JingleIBBTransportSession.java index 84d950051..27f9ceec3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_ibb/JingleIBBTransportSession.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/transports/jingle_ibb/JingleIBBTransportSession.java @@ -89,7 +89,7 @@ public class JingleIBBTransportSession extends JingleTransportSession