mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Add createCandidateUsed
This commit is contained in:
parent
a3d6562791
commit
d7cf19aca7
2 changed files with 35 additions and 16 deletions
|
@ -177,7 +177,9 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
||||||
return jingle;
|
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();
|
Jingle.Builder jb = Jingle.getBuilder();
|
||||||
jb.setSessionId(sessionId).setAction(JingleAction.transport_info).setInitiator(initiator);
|
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);
|
cb.setSenders(senders).setCreator(creator).setName(name);
|
||||||
|
|
||||||
JingleS5BTransport.Builder tb = JingleS5BTransport.getBuilder();
|
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 jingle = jb.addJingleContent(cb.setTransport(tb.build()).build()).build();
|
||||||
jingle.setTo(remote);
|
jingle.setTo(remote);
|
||||||
|
@ -193,4 +195,22 @@ public final class JingleS5BTransportManager extends JingleTransportManager<Jing
|
||||||
return jingle;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,11 +239,13 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
return IQ.createResultIQ(candidateUsed);
|
return IQ.createResultIQ(candidateUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect(JingleS5BTransportCandidate candidate) {
|
private void connect(JingleS5BTransportCandidate candidate) throws SmackException.NotConnectedException, InterruptedException {
|
||||||
JingleSession jSession = jingleSession.get();
|
JingleSession jSession = jingleSession.get();
|
||||||
if (jSession == null) {
|
if (jSession == null) {
|
||||||
throw new NullPointerException("Lost reference to JingleSession.");
|
throw new NullPointerException("Lost reference to JingleSession.");
|
||||||
}
|
}
|
||||||
|
JingleContent content = jSession.getContents().get(0);
|
||||||
|
|
||||||
// Used candidate belongs to remote.
|
// Used candidate belongs to remote.
|
||||||
if (candidate == localUsedCandidate) {
|
if (candidate == localUsedCandidate) {
|
||||||
|
|
||||||
|
@ -286,20 +288,17 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
SmackException.NotConnectedException | InterruptedException e) {
|
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
|
//send proxy error
|
||||||
jSession.getConnection().sendStanza(transportManager.createProxyError(
|
jSession.getConnection().sendStanza(transportManager.createProxyError(
|
||||||
jSession.getRemote(), jSession.getInitiator(), jSession.getSessionId(),
|
jSession.getRemote(), jSession.getInitiator(), jSession.getSessionId(),
|
||||||
content.getSenders(), content.getCreator(), content.getName(),
|
content.getSenders(), content.getCreator(), content.getName(),
|
||||||
((JingleS5BTransport) localTransport).getStreamId()));
|
((JingleS5BTransport) localTransport).getStreamId()));
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e1) {
|
|
||||||
LOGGER.log(Level.SEVERE, "Could not send proxy error.", e);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//send candidate-activate
|
|
||||||
|
|
||||||
|
transportManager.createCandidateActivated(jSession.getRemote(), jSession.getInitiator(), jSession.getSessionId(),
|
||||||
|
content.getSenders(), content.getCreator(), content.getName(), ((JingleS5BTransport) localTransport).getStreamId(),
|
||||||
|
candidate.getCandidateId());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue