org.jivesoftware.smackx.jingle.nat
Class TransportNegotiator

java.lang.Object
  extended by org.jivesoftware.smackx.jingle.JingleNegotiator
      extended by org.jivesoftware.smackx.jingle.nat.TransportNegotiator
Direct Known Subclasses:
TransportNegotiator.Ice, TransportNegotiator.RawUdp

public abstract class TransportNegotiator
extends JingleNegotiator

Transport negotiator.

This class is responsible for managing the transport negotiation process, handling all the packet interchange and the stage control.

Author:
Alvaro Saurin

Nested Class Summary
static class TransportNegotiator.Ice
          Ice transport negotiator.
static class TransportNegotiator.RawUdp
          Raw-UDP transport negotiator
 
Field Summary
static int CANDIDATES_ACCEPT_PERIOD
           
 
Constructor Summary
TransportNegotiator(JingleSession session, TransportResolver transResolver, ContentNegotiator parentNegotiator)
          Default constructor.
 
Method Summary
abstract  boolean acceptableTransportCandidate(TransportCandidate tc, java.util.List<TransportCandidate> localCandidates)
          Return true if the transport candidate is acceptable for the current negotiator.
 void close()
          Called from above to session-terminate.
 java.util.List<IQ> dispatchIncomingPacket(IQ iq, java.lang.String id)
          Dispatch an incoming packet.
 TransportCandidate getAcceptedLocalCandidate()
          Get the best accepted local candidate we have offered.
 TransportCandidate getBestLocalCandidate()
          Obtain the best local candidate we want to offer.
abstract  TransportCandidate getBestRemoteCandidate()
          Obtain the best common transport candidate obtained in the negotiation.
 JingleTransport getJingleTransport()
          Return a JingleTransport that best reflects this transport negotiator.
abstract  JingleTransport getJingleTransport(TransportCandidate cand)
          Get a new instance of the right TransportNegotiator class with this candidate.
 java.util.List<TransportCandidate> getOfferedCandidates()
           
 java.util.Iterator getValidRemoteCandidates()
          Get an iterator for the list of valid (ie, checked) remote candidates.
 boolean isFullyEstablished()
          Return true if the transport is fully established.
 
Methods inherited from class org.jivesoftware.smackx.jingle.JingleNegotiator
addExpectedId, addListener, getConnection, getNegotiatorState, getSession, isExpectedId, isStarted, removeExpectedId, removeListener, setNegotiatorState, setSession, start
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CANDIDATES_ACCEPT_PERIOD

public static final int CANDIDATES_ACCEPT_PERIOD
See Also:
Constant Field Values
Constructor Detail

TransportNegotiator

public TransportNegotiator(JingleSession session,
                           TransportResolver transResolver,
                           ContentNegotiator parentNegotiator)
Default constructor.

Parameters:
js - The Jingle session
transResolver - The JingleTransportManager to use
Method Detail

getJingleTransport

public abstract JingleTransport getJingleTransport(TransportCandidate cand)
Get a new instance of the right TransportNegotiator class with this candidate.

Returns:
A TransportNegotiator instance

acceptableTransportCandidate

public abstract boolean acceptableTransportCandidate(TransportCandidate tc,
                                                     java.util.List<TransportCandidate> localCandidates)
Return true if the transport candidate is acceptable for the current negotiator.

Returns:
true if the transport candidate is acceptable

getBestLocalCandidate

public final TransportCandidate getBestLocalCandidate()
Obtain the best local candidate we want to offer.

Returns:
the best local candidate

getAcceptedLocalCandidate

public TransportCandidate getAcceptedLocalCandidate()
Get the best accepted local candidate we have offered.

Returns:
a transport candidate we have offered.

close

public void close()
Called from above to session-terminate.

Overrides:
close in class JingleNegotiator

getJingleTransport

public JingleTransport getJingleTransport()
Return a JingleTransport that best reflects this transport negotiator.


getOfferedCandidates

public java.util.List<TransportCandidate> getOfferedCandidates()

getBestRemoteCandidate

public abstract TransportCandidate getBestRemoteCandidate()
Obtain the best common transport candidate obtained in the negotiation.

Returns:
the bestRemoteCandidate

isFullyEstablished

public final boolean isFullyEstablished()
Return true if the transport is fully established.

Returns:
true if the transport is fully established.

getValidRemoteCandidates

public final java.util.Iterator getValidRemoteCandidates()
Get an iterator for the list of valid (ie, checked) remote candidates.

Returns:
The iterator for the list of valid (ie, already checked) remote candidates.

dispatchIncomingPacket

public final java.util.List<IQ> dispatchIncomingPacket(IQ iq,
                                                       java.lang.String id)
                                                throws XMPPException
Dispatch an incoming packet. The method is responsible for recognizing the packet type and, depending on the current state, deliverying the packet to the right event handler and wait for a response.

Specified by:
dispatchIncomingPacket in class JingleNegotiator
Parameters:
iq - the packet received
id - the ID of the response that will be sent
Returns:
the new Jingle packet to send.
Throws:
XMPPException