String ibbSessionId = UUID.randomUUID().toString();
InBandBytestreamsTransportMethod ibbTransportMethod = new InBandBytestreamsTransportMethod(ibbSessionId, 4096);
Jingle.Content content = new Jingle.Content("a-file-offer", Jingle.Content.Creator.INITIATOR, jingleFileTransfer, ibbTransportMethod);
final JingleSession jingleSession = jingleManager.createSession(responder, content);
final Lock lock = new ReentrantLock();
final Condition condition = lock.newCondition();
final Jingle[] response = new Jingle[1];
jingleSession.addJingleListener(new JingleListener() {
@Override
public void jingleReceived(JingleEvent e) {
if (e.getJingle().getAction() == Jingle.Action.SESSION_ACCEPT || e.getJingle().getAction() == Jingle.Action.SESSION_TERMINATE) {
lock.lock();
try {
response[0] = e.getJingle();
condition.signalAll();
} finally {
lock.unlock();
}
}
}
});
jingleSession.initiate();
// Wait until the session is either accepted or declined (terminated).
lock.lock();
try {
if (!condition.await(timeout, TimeUnit.MILLISECONDS)) {