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.
  • Field Details

  • Constructor Details

    • TransportResolver

      protected TransportResolver()
      Default constructor.
  • Method Details

    • getType

      public TransportResolver.Type getType()
    • setType

      public void setType(TransportResolver.Type type)
    • initialize

      public abstract void initialize() throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedException
      Initialize 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.XMPPException
      Clear 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.XMPPException
      Cancel 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

      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 List<TransportResolverListener> 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

      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 org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedException
      Initialize 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.