Class TransportResolver
- java.lang.Object
-
- org.jivesoftware.smackx.jingleold.nat.TransportResolver
-
- Direct Known Subclasses:
BasicResolver
,BridgedResolver
,FixedResolver
,ICEResolver
,STUNResolver
public abstract class TransportResolver extends Object
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 Modifier and Type Class Description static class
TransportResolver.Type
-
Field Summary
Fields Modifier and Type Field Description protected List<TransportCandidate>
candidates
static int
CHECK_TIMEOUT
TransportResolver.Type
type
-
Constructor Summary
Constructors Modifier Constructor Description protected
TransportResolver()
Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addCandidate(TransportCandidate cand)
Add a new transport candidatevoid
addListener(TransportResolverListener li)
Add a transport resolver listener.abstract void
cancel()
Cancel any asynchronous resolution operation.void
clear()
Clear the list of candidates and start a new resolution process.protected void
clearCandidates()
Clear the list of candidateTransportCandidate
getCandidate(int i)
Get the n-th candidate.int
getCandidateCount()
Get the number of transport candidates.Iterator<TransportCandidate>
getCandidates()
Get an iterator for the list of candidates.List<TransportCandidate>
getCandidatesList()
Get the list of candidates.protected int
getFreePort()
Obtain a free port we can use.ArrayList<TransportResolverListener>
getListenersList()
Get the list of listeners.TransportCandidate
getPreferredCandidate()
Get the candidate with the highest preference.TransportResolver.Type
getType()
abstract void
initialize()
Initialize the Resolver.void
initializeAndWait()
Initialize Transport Resolver and wait until it is completely uninitialized.boolean
isInitialized()
Check if the Transport Resolver is initialized.boolean
isResolved()
Return true if the resolver has finished the search for transport candidates.boolean
isResolving()
Return true if the resolver is working.void
removeListener(TransportResolverListener li)
Removes a transport resolver listener.abstract void
resolve(JingleSession session)
Start a the resolution.void
setInitialized()
Set the Transport Resolver as initialized.protected void
setResolveEnd()
Indicate the end of the resolution process.protected void
setResolveInit()
Indicate the beginning of the resolution process.void
setType(TransportResolver.Type type)
protected void
triggerCandidateAdded(TransportCandidate cand)
Trigger a new candidate added event.
-
-
-
Field Detail
-
type
public TransportResolver.Type type
-
CHECK_TIMEOUT
public static final int CHECK_TIMEOUT
- See Also:
- Constant Field Values
-
candidates
protected final List<TransportCandidate> candidates
-
-
Constructor Detail
-
TransportResolver
protected TransportResolver()
Default constructor.
-
-
Method Detail
-
getType
public TransportResolver.Type getType()
-
setType
public void setType(TransportResolver.Type type)
-
initialize
public abstract void initialize() throws XMPPException, SmackException, InterruptedException
Initialize the Resolver.- Throws:
XMPPException
- if an XMPP protocol error was received.SmackException
- if Smack detected an exceptional situation.InterruptedException
- if the calling thread was interrupted.
-
resolve
public abstract void resolve(JingleSession session) throws XMPPException, SmackException, InterruptedException
Start a the resolution.- Parameters:
session
- the Jingle session.- Throws:
XMPPException
- if an XMPP protocol error was received.SmackException
- if Smack detected an exceptional situation.InterruptedException
- if the calling thread was interrupted.
-
clear
public void clear() throws XMPPException
Clear the list of candidates and start a new resolution process.- Throws:
XMPPException
- if an XMPP protocol error was received.
-
cancel
public abstract void cancel() throws XMPPException
Cancel any asynchronous resolution operation.- Throws:
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
public void addListener(TransportResolverListener li)
Add a transport resolver listener.- Parameters:
li
- The transport resolver listener to be added.
-
removeListener
public void removeListener(TransportResolverListener li)
Removes a transport resolver listener.- Parameters:
li
- The transport resolver listener to be removed
-
getListenersList
public ArrayList<TransportResolverListener> getListenersList()
Get the list of listeners.- Returns:
- the list of listeners
-
triggerCandidateAdded
protected void triggerCandidateAdded(TransportCandidate cand) throws SmackException.NotConnectedException, InterruptedException
Trigger a new candidate added event.- Parameters:
cand
- The candidate added to the list of candidates.- Throws:
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 SmackException.NotConnectedException, InterruptedException
Add a new transport candidate- Parameters:
cand
- The candidate to add- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getCandidates
public Iterator<TransportCandidate> getCandidates()
Get an iterator for the list of candidates.- Returns:
- an iterator
-
getPreferredCandidate
public TransportCandidate 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
public List<TransportCandidate> getCandidatesList()
Get the list of candidates.- Returns:
- the list of transport candidates
-
getCandidate
public TransportCandidate getCandidate(int i)
Get the n-th candidate.- Parameters:
i
- the index of the candidate.- Returns:
- a transport candidate
-
initializeAndWait
public void initializeAndWait() throws XMPPException, SmackException, InterruptedException
Initialize Transport Resolver and wait until it is completely uninitialized.- Throws:
XMPPException
- if an XMPP protocol error was received.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.
-
-