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

Add createCandidateUsed

This commit is contained in:
vanitasvitae 2017-06-25 16:39:02 +02:00
parent a3d6562791
commit d7cf19aca7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 35 additions and 16 deletions

View file

@ -177,7 +177,9 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
return jingle;
}
public Jingle createProxyError(FullJid remote, FullJid initiator, 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).setInitiator(initiator);
@ -185,7 +187,7 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
cb.setSenders(senders).setCreator(creator).setName(name);
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
tb.setStreamId(sessionId).setProxyError();
tb.setStreamId(sessionId).setProxyError().setStreamId(streamId);
Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
jingle.setTo(remote);
@ -193,4 +195,22 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
return jingle;
}
public Jingle createCandidateActivated(FullJid remote, FullJid initiator, String sessionId,
JingleContent.Senders senders, JingleContent.Creator creator,
String name, String streamId, String candidateId) {
Jingle.Builder jb = Jingle.getBuilder();
jb.setInitiator(initiator).setSessionId(sessionId).setAction(JingleAction.transport_info);
JingleContent.Builder cb = JingleContent.getBuilder();
cb.setName(name).setCreator(creator).setSenders(senders);
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
tb.setStreamId(streamId).setCandidateActivated(candidateId);
Jingle jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
jingle.setFrom(getConnection().getUser().asFullJidOrThrow());
jingle.setTo(remote);
return jingle;
}
}

View file

@ -239,11 +239,13 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
return IQ.createResultIQ(candidateUsed);
}
private void connect(JingleS5BTransportCandidate candidate) {
private void connect(JingleS5BTransportCandidate candidate) throws SmackException.NotConnectedException, InterruptedException {
JingleSession jSession = jingleSession.get();
if (jSession == null) {
throw new NullPointerException("Lost reference to JingleSession.");
}
JingleContent content = jSession.getContents().get(0);
// Used candidate belongs to remote.
if (candidate == localUsedCandidate) {
@ -286,20 +288,17 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
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 proxy error
jSession.getConnection().sendStanza(transportManager.createProxyError(
jSession.getRemote(), jSession.getInitiator(), jSession.getSessionId(),
content.getSenders(), content.getCreator(), content.getName(),
((JingleS5BTransport) localTransport).getStreamId()));
return;
}
//send candidate-activate
transportManager.createCandidateActivated(jSession.getRemote(), jSession.getInitiator(), jSession.getSessionId(),
content.getSenders(), content.getCreator(), content.getName(), ((JingleS5BTransport) localTransport).getStreamId(),
candidate.getCandidateId());
}
} else {