mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-10-31 17:25:58 +01:00
Improve comparison of transportmanagers
This commit is contained in:
parent
4234e1d5ab
commit
3915a71824
4 changed files with 33 additions and 5 deletions
|
@ -29,4 +29,11 @@ public interface JingleTransportManager extends Comparable<JingleTransportManage
|
||||||
JingleTransport<?> createTransport(JingleContent content);
|
JingleTransport<?> createTransport(JingleContent content);
|
||||||
|
|
||||||
JingleTransport<?> createTransport(JingleContent content, JingleTransport<?> peersTransport);
|
JingleTransport<?> createTransport(JingleContent content, JingleTransport<?> peersTransport);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a (usually) positive integer, which is used to define a strict order over the set of available transport
|
||||||
|
* managers.
|
||||||
|
* @return priority.
|
||||||
|
*/
|
||||||
|
int getPriority();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,13 @@ public class JingleIBBTransportManager extends Manager implements JingleTranspor
|
||||||
return new JingleIBBTransport(other.getSid(), (short) Math.min(other.getBlockSize(), MAX_BLOCKSIZE));
|
return new JingleIBBTransport(other.getSid(), (short) Math.min(other.getBlockSize(), MAX_BLOCKSIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(JingleTransportManager manager) {
|
public int compareTo(JingleTransportManager manager) {
|
||||||
return -1; // We are literally the worst.
|
return Integer.compare(getPriority(), manager.getPriority());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.jivesoftware.smack.SmackException;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
import org.jivesoftware.smack.packet.Stanza;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession;
|
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy;
|
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Utils;
|
import org.jivesoftware.smackx.bytestreams.socks5.Socks5Utils;
|
||||||
|
@ -325,9 +326,9 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCandidateActivate(JingleS5BTransportInfoElement info) {
|
private void handleCandidateActivate(JingleS5BTransportInfoElement info) {
|
||||||
//Socks5BytestreamSession bs = new Socks5BytestreamSession(ourChoice.socket,
|
this.bytestreamSession = new Socks5BytestreamSession(getSelectedCandidate().getSocket(),
|
||||||
// ourChoice.candidate.getJid().asBareJid().equals(jingleSession.getRemote().asBareJid()));
|
getSelectedCandidate().getStreamHost().getJID().asBareJid().equals(getParent().getParent().getPeer().asBareJid()));
|
||||||
//callback.onSessionInitiated(bs);
|
getParent().onTransportReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCandidateError(JingleS5BTransportInfoElement info) {
|
private void handleCandidateError(JingleS5BTransportInfoElement info) {
|
||||||
|
@ -352,4 +353,14 @@ public class JingleS5BTransport extends JingleTransport<JingleS5BTransportElemen
|
||||||
* Kinda depressing, isn't it?
|
* Kinda depressing, isn't it?
|
||||||
*/
|
*/
|
||||||
private final static JingleS5BTransportCandidate CANDIDATE_FAILURE = new JingleS5BTransportCandidate(null, null, -1, null);
|
private final static JingleS5BTransportCandidate CANDIDATE_FAILURE = new JingleS5BTransportCandidate(null, null, -1, null);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isNonFatalException(Exception exception) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleStanza(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,11 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
||||||
return new JingleS5BTransport(content, transport, candidates);
|
return new JingleS5BTransport(content, transport, candidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority() {
|
||||||
|
return 10000;
|
||||||
|
}
|
||||||
|
|
||||||
private List<JingleTransportCandidate<?>> collectCandidates() {
|
private List<JingleTransportCandidate<?>> collectCandidates() {
|
||||||
List<JingleTransportCandidate<?>> candidates = new ArrayList<>();
|
List<JingleTransportCandidate<?>> candidates = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -236,7 +241,7 @@ public final class JingleS5BTransportManager extends Manager implements JingleTr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(JingleTransportManager manager) {
|
public int compareTo(JingleTransportManager manager) {
|
||||||
return 1; // We are #1!
|
return Integer.compare(getPriority(), manager.getPriority());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConnectionListener connectionListener = new ConnectionListener() {
|
private ConnectionListener connectionListener = new ConnectionListener() {
|
||||||
|
|
Loading…
Reference in a new issue