mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Even more progress
This commit is contained in:
parent
5ebd07ac3c
commit
a3d6562791
2 changed files with 34 additions and 12 deletions
|
@ -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,
|
JingleContent.Creator contentCreator, String contentName, String streamId,
|
||||||
String candidateId) {
|
String candidateId) {
|
||||||
Jingle.Builder jb = Jingle.getBuilder();
|
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();
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||||
cb.setName(contentName).setCreator(contentCreator).setSenders(contentSenders);
|
cb.setName(contentName).setCreator(contentCreator).setSenders(contentSenders);
|
||||||
|
@ -160,9 +160,9 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
||||||
return jingle;
|
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();
|
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();
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||||
cb.setName(name).setCreator(creator).setSenders(senders);
|
cb.setName(name).setCreator(creator).setSenders(senders);
|
||||||
|
@ -177,13 +177,17 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
||||||
return jingle;
|
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();
|
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.setTo(remote);
|
||||||
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
|
||||||
return jingle;
|
return jingle;
|
||||||
|
|
|
@ -157,13 +157,13 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
connectedSocket = socket;
|
connectedSocket = socket;
|
||||||
localUsedCandidate = workedForUs;
|
localUsedCandidate = workedForUs;
|
||||||
|
|
||||||
response = transportManager.createCandidateUsed(jSession.getRemote(),
|
response = transportManager.createCandidateUsed(jSession.getRemote(), jSession.getInitiator(),
|
||||||
jSession.getSessionId(), content.getSenders(), content.getCreator(),
|
jSession.getSessionId(), content.getSenders(), content.getCreator(),
|
||||||
content.getName(), receivedTransport.getStreamId(), localUsedCandidate.getCandidateId());
|
content.getName(), receivedTransport.getStreamId(), localUsedCandidate.getCandidateId());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
localError = true;
|
localError = true;
|
||||||
response = transportManager.createCandidateError(jSession.getRemote(),
|
response = transportManager.createCandidateError(jSession.getRemote(), jSession.getInitiator(),
|
||||||
jSession.getSessionId(), content.getSenders(), content.getCreator(),
|
jSession.getSessionId(), content.getSenders(), content.getCreator(),
|
||||||
content.getName(), receivedTransport.getStreamId());
|
content.getName(), receivedTransport.getStreamId());
|
||||||
}
|
}
|
||||||
|
@ -275,16 +275,32 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
}
|
}
|
||||||
callback.onSessionInitiated(new Socks5BytestreamSession(connectedSocket, true));
|
callback.onSessionInitiated(new Socks5BytestreamSession(connectedSocket, true));
|
||||||
} else {
|
} else {
|
||||||
|
//activate proxy
|
||||||
Bytestream activateProxy = new Bytestream(((JingleS5BTransport) localTransport).getStreamId());
|
Bytestream activateProxy = new Bytestream(((JingleS5BTransport) localTransport).getStreamId());
|
||||||
activateProxy.setToActivate(candidate.getJid());
|
activateProxy.setToActivate(candidate.getJid());
|
||||||
activateProxy.setTo(candidate.getJid());
|
activateProxy.setTo(candidate.getJid());
|
||||||
|
Bytestream result;
|
||||||
try {
|
try {
|
||||||
jSession.getConnection().createStanzaCollectorAndSend(activateProxy).nextResultOrThrow();
|
result = jSession.getConnection().createStanzaCollectorAndSend(activateProxy).nextResultOrThrow();
|
||||||
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
|
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException |
|
||||||
|
SmackException.NotConnectedException | InterruptedException e) {
|
||||||
LOGGER.log(Level.SEVERE, "Could not activate proxy server: " + e, 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 {
|
} else {
|
||||||
|
|
||||||
|
@ -300,7 +316,9 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
public IQ handleCandidateError(Jingle candidateError) {
|
public IQ handleCandidateError(Jingle candidateError) {
|
||||||
remoteError = true;
|
remoteError = true;
|
||||||
|
|
||||||
closeIfBothSidesFailed();
|
if (closeIfBothSidesFailed()) {
|
||||||
|
return IQ.createResultIQ(candidateError);
|
||||||
|
}
|
||||||
|
|
||||||
if (localUsedCandidate.getType() != JingleS5BTransportCandidate.Type.proxy) {
|
if (localUsedCandidate.getType() != JingleS5BTransportCandidate.Type.proxy) {
|
||||||
//TODO: Connect
|
//TODO: Connect
|
||||||
|
|
Loading…
Reference in a new issue