Class TransportResolver
java.lang.Object
org.jivesoftware.smackx.jingleold.nat.TransportResolver
- Direct Known Subclasses:
BasicResolver,BridgedResolver,FixedResolver,ICEResolver,STUNResolver
A TransportResolver is used for obtaining a list of valid transport
candidates. A transport candidate is composed by an IP address and a port number.
It is called candidate, because it can be elected or not.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd a new transport candidatevoidAdd a transport resolver listener.abstract voidcancel()Cancel any asynchronous resolution operation.voidclear()Clear the list of candidates and start a new resolution process.protected voidClear the list of candidategetCandidate(int i) Get the n-th candidate.intGet the number of transport candidates.Get an iterator for the list of candidates.Get the list of candidates.protected intObtain a free port we can use.Get the list of listeners.Get the candidate with the highest preference.getType()abstract voidInitialize the Resolver.voidInitialize Transport Resolver and wait until it is completely uninitialized.booleanCheck if the Transport Resolver is initialized.booleanReturn true if the resolver has finished the search for transport candidates.booleanReturn true if the resolver is working.voidRemoves a transport resolver listener.abstract voidresolve(JingleSession session) Start a the resolution.voidSet the Transport Resolver as initialized.protected voidIndicate the end of the resolution process.protected voidIndicate the beginning of the resolution process.voidprotected voidTrigger a new candidate added event.
-
Field Details
-
type
-
CHECK_TIMEOUT
public static final int CHECK_TIMEOUT- See Also:
-
candidates
-
-
Constructor Details
-
TransportResolver
protected TransportResolver()Default constructor.
-
-
Method Details
-
getType
-
setType
-
initialize
public abstract void initialize() throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedExceptionInitialize the Resolver.- Throws:
org.jivesoftware.smack.XMPPException- if an XMPP protocol error was received.org.jivesoftware.smack.SmackException- if Smack detected an exceptional situation.InterruptedException- if the calling thread was interrupted.
-
resolve
public abstract void resolve(JingleSession session) throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedException Start a the resolution.- Parameters:
session- the Jingle session.- Throws:
org.jivesoftware.smack.XMPPException- if an XMPP protocol error was received.org.jivesoftware.smack.SmackException- if Smack detected an exceptional situation.InterruptedException- if the calling thread was interrupted.
-
clear
public void clear() throws org.jivesoftware.smack.XMPPExceptionClear the list of candidates and start a new resolution process.- Throws:
org.jivesoftware.smack.XMPPException- if an XMPP protocol error was received.
-
cancel
public abstract void cancel() throws org.jivesoftware.smack.XMPPExceptionCancel any asynchronous resolution operation.- Throws:
org.jivesoftware.smack.XMPPException- if an XMPP protocol error was received.
-
isResolving
public boolean isResolving()Return true if the resolver is working.- Returns:
- true if the resolver is working.
-
isResolved
public boolean isResolved()Return true if the resolver has finished the search for transport candidates.- Returns:
- true if the search has finished
-
setInitialized
public void setInitialized()Set the Transport Resolver as initialized. -
isInitialized
public boolean isInitialized()Check if the Transport Resolver is initialized.- Returns:
- true if initialized
-
setResolveInit
protected void setResolveInit()Indicate the beginning of the resolution process. This method must be used by subclasses at the beginning of their resolve() method. -
setResolveEnd
protected void setResolveEnd()Indicate the end of the resolution process. This method must be used by subclasses at the beginning of their resolve() method. -
addListener
Add a transport resolver listener.- Parameters:
li- The transport resolver listener to be added.
-
removeListener
Removes a transport resolver listener.- Parameters:
li- The transport resolver listener to be removed
-
getListenersList
Get the list of listeners.- Returns:
- the list of listeners
-
triggerCandidateAdded
protected void triggerCandidateAdded(TransportCandidate cand) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException Trigger a new candidate added event.- Parameters:
cand- The candidate added to the list of candidates.- Throws:
org.jivesoftware.smack.SmackException.NotConnectedException- if the XMPP connection is not connected.InterruptedException- if the calling thread was interrupted.
-
clearCandidates
protected void clearCandidates()Clear the list of candidate -
addCandidate
protected void addCandidate(TransportCandidate cand) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException Add a new transport candidate- Parameters:
cand- The candidate to add- Throws:
org.jivesoftware.smack.SmackException.NotConnectedException- if the XMPP connection is not connected.InterruptedException- if the calling thread was interrupted.
-
getCandidates
Get an iterator for the list of candidates.- Returns:
- an iterator
-
getPreferredCandidate
Get the candidate with the highest preference.- Returns:
- The best candidate, according to the preference order.
-
getCandidateCount
public int getCandidateCount()Get the number of transport candidates.- Returns:
- The length of the transport candidates list.
-
getCandidatesList
Get the list of candidates.- Returns:
- the list of transport candidates
-
getCandidate
Get the n-th candidate.- Parameters:
i- the index of the candidate.- Returns:
- a transport candidate
-
initializeAndWait
public void initializeAndWait() throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedExceptionInitialize Transport Resolver and wait until it is completely uninitialized.- Throws:
org.jivesoftware.smack.XMPPException- if an XMPP protocol error was received.org.jivesoftware.smack.SmackException- if Smack detected an exceptional situation.InterruptedException- if the calling thread was interrupted.
-
getFreePort
protected int getFreePort()Obtain a free port we can use.- Returns:
- A free port number.
-