@Override
public JingleMediaSession createMediaSession(PayloadType payload,
TransportCandidate remoteCandidate,
TransportCandidate localCandidate, JingleSession jingleSession) {
final JID remoteJID = isInitiator(jingleSession) ? new JID(
jingleSession.getResponder()) : new JID(
jingleSession.getInitiator());
final JingleFileTransferSession newSession = new JingleFileTransferSession(
payload, remoteCandidate, localCandidate, null, jingleSession);
if (newSession.isConnected()) {
log.debug("Jingle [" + remoteJID.getName()
+ "] Media Session - Success using "
+ NetTransferMode.JINGLETCP);
if (!isInitiator(jingleSession)) {
try {
final BinaryChannel channel = new BinaryChannel(
newSession, getDefaultNetTransferMode());
listener.connectionChanged(remoteJID,
new BinaryChannelConnection(remoteJID, channel,
listener), true);
} catch (IOException e) {
log.error(
"could not connect to " + remoteJID.getName(), e);
// throw new CausedIOException("Could not connect to "
// + remoteJID.getName(), e);
}
} else {
sessions.put(remoteJID.toString(), newSession);
}
} else {
log.debug("Jingle [" + remoteJID.getName()
+ "] Media Session - Failure");
}
return newSession;
}