1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-26 04:28:00 +01:00

Even more progress

This commit is contained in:
vanitasvitae 2017-06-25 16:28:59 +02:00
parent 5ebd07ac3c
commit a3d6562791
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 34 additions and 12 deletions

View file

@ -141,11 +141,11 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
}
}
public Jingle createCandidateUsed(FullJid recipient, String sessionId, JingleContent.Senders contentSenders,
public Jingle createCandidateUsed(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Senders contentSenders,
JingleContent.Creator contentCreator, String contentName, String streamId,
String candidateId) {
Jingle.Builder jb = Jingle.getBuilder();
jb.setSessionId(sessionId).setInitiator(recipient).setAction(JingleAction.transport_info);
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
JingleContent.Builder cb = JingleContent.getBuilder();
cb.setName(contentName).setCreator(contentCreator).setSenders(contentSenders);
@ -160,9 +160,9 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
return jingle;
}
public Jingle createCandidateError(FullJid remote, String sessionId, JingleContent.Senders senders, JingleContent.Creator creator, String name, String streamId) {
public Jingle createCandidateError(FullJid remote, FullJid initiator, String sessionId, JingleContent.Senders senders, JingleContent.Creator creator, String name, String streamId) {
Jingle.Builder jb = Jingle.getBuilder();
jb.setSessionId(sessionId).setInitiator(remote).setAction(JingleAction.transport_info);
jb.setSessionId(sessionId).setInitiator(initiator).setAction(JingleAction.transport_info);
JingleContent.Builder cb = JingleContent.getBuilder();
cb.setName(name).setCreator(creator).setSenders(senders);
@ -177,13 +177,17 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
return jingle;
}
public Jingle createProxyError(FullJid remote, String sessionId, JingleContent.Senders senders, JingleContent.Creator creator, String name, String streamId) {
public Jingle createProxyError(FullJid remote, FullJid initiator, String sessionId, JingleContent.Senders senders, JingleContent.Creator creator, String name, String streamId) {
Jingle.Builder jb = Jingle.getBuilder();
jb.setSessionId(sessionId).setAction(JingleAction.transport_info);
jb.setSessionId(sessionId).setAction(JingleAction.transport_info).setInitiator(initiator);
JingleContent.Builder cb = JingleContent.getBuilder();
cb.setSenders(senders).setCreator(creator).setName(name);
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
tb.setStreamId(sessionId).setProxyError();
Jingle jingle = jb.build();
Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
jingle.setTo(remote);
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
return jingle;

View file

@ -157,13 +157,13 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
connectedSocket = socket;
localUsedCandidate = workedForUs;
response = transportManager.createCandidateUsed(jSession.getRemote(),
response = transportManager.createCandidateUsed(jSession.getRemote(), jSession.getInitiator(),
jSession.getSessionId(), content.getSenders(), content.getCreator(),
content.getName(), receivedTransport.getStreamId(), localUsedCandidate.getCandidateId());
} else {
localError = true;
response = transportManager.createCandidateError(jSession.getRemote(),
response = transportManager.createCandidateError(jSession.getRemote(), jSession.getInitiator(),
jSession.getSessionId(), content.getSenders(), content.getCreator(),
content.getName(), receivedTransport.getStreamId());
}
@ -275,15 +275,31 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
}
callback.onSessionInitiated(new Socks5BytestreamSession(connectedSocket, true));
} else {
//activate proxy
Bytestream activateProxy = new Bytestream(((JingleS5BTransport) localTransport).getStreamId());
activateProxy.setToActivate(candidate.getJid());
activateProxy.setTo(candidate.getJid());
Bytestream result;
try {
jSession.getConnection().createStanzaCollectorAndSend(activateProxy).nextResultOrThrow();
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
result = jSession.getConnection().createStanzaCollectorAndSend(activateProxy).nextResultOrThrow();
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException |
SmackException.NotConnectedException | InterruptedException e) {
LOGGER.log(Level.SEVERE, "Could not activate proxy server: " + e, e);
JingleContent content = jSession.getContents().get(0);
try {
//send proxy error
jSession.getConnection().sendStanza(transportManager.createProxyError(
jSession.getRemote(), jSession.getInitiator(), jSession.getSessionId(),
content.getSenders(), content.getCreator(), content.getName(),
((JingleS5BTransport) localTransport).getStreamId()));
} catch (SmackException.NotConnectedException | InterruptedException e1) {
LOGGER.log(Level.SEVERE, "Could not send proxy error.", e);
return;
}
}
//send candidate-activate
}
} else {
@ -300,7 +316,9 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
public IQ handleCandidateError(Jingle candidateError) {
remoteError = true;
closeIfBothSidesFailed();
if (closeIfBothSidesFailed()) {
return IQ.createResultIQ(candidateError);
}
if (localUsedCandidate.getType() != JingleS5BTransportCandidate.Type.proxy) {
//TODO: Connect