1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 20:42:06 +01:00

JIBB works

This commit is contained in:
vanitasvitae 2017-06-24 12:14:05 +02:00
parent c4ef2c9552
commit a101de29fd
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 37 additions and 38 deletions

View file

@ -135,29 +135,28 @@ public class IncomingJingleFileOffer extends JingleFileTransferSession implement
return; return;
} }
queued.add(threadPool.submit(new Runnable() { state = State.active;
transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() {
@Override @Override
public void run() { public void onSessionInitiated(BytestreamSession bytestreamSession) {
try { LOGGER.log(Level.INFO, "BEFORE THREAD START!");
state = State.active; receivingThread = new ReceiveTask(bytestreamSession, file, target);
transportSession.initiateIncomingSession(new JingleTransportInitiationCallback() { queued.add(threadPool.submit(receivingThread));
@Override LOGGER.log(Level.INFO,"AFTER THREAD START!");
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);
}
} }
}));
@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 @Override

View file

@ -103,24 +103,22 @@ public class OutgoingJingleFileOffer extends JingleFileTransferSession {
LOGGER.log(Level.INFO, "Session was accepted. Initiate Bytestream."); LOGGER.log(Level.INFO, "Session was accepted. Initiate Bytestream.");
state = State.active; 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 transportSession.processJingle(sessionAccept);
public void onException(Exception e) {
LOGGER.log(Level.SEVERE, "Cannot create outgoing Bytestream session: ", e); 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); return jutil.createAck(sessionAccept);
} }

View file

@ -89,7 +89,7 @@ public class JingleIBBTransportSession extends JingleTransportSession<JingleIBBT
public void incomingBytestreamRequest(BytestreamRequest request) { public void incomingBytestreamRequest(BytestreamRequest request) {
if (request.getFrom().asFullJidIfPossible().equals(jingleSession.get().getRemote()) if (request.getFrom().asFullJidIfPossible().equals(jingleSession.get().getRemote())
&& request.getSessionID().equals(ibbTransport.getSessionId())) { && request.getSessionID().equals(ibbTransport.getSessionId())) {
LOGGER.log(Level.INFO,"MATCH! Create bytesteam session.");
BytestreamSession session; BytestreamSession session;
try { try {
@ -99,6 +99,8 @@ public class JingleIBBTransportSession extends JingleTransportSession<JingleIBBT
return; return;
} }
callback.onSessionInitiated(session); callback.onSessionInitiated(session);
} else {
LOGGER.log(Level.SEVERE, "MISSMATCH");
} }
} }
}); });