org.jivesoftware.smackx.jingle
Class JingleNegotiator

java.lang.Object
  extended by org.jivesoftware.smackx.jingle.JingleNegotiator
Direct Known Subclasses:
ContentNegotiator, JingleSession, MediaNegotiator, TransportNegotiator

public abstract class JingleNegotiator
extends java.lang.Object

Basic Jingle negotiator.

JingleNegotiator implements some basic behavior for every Jingle negotiation. It implements a "state" pattern: each stage should process Jingle packets and act depending on the current state in the negotiation...

Author:
Alvaro Saurin, Jeff Williams

Constructor Summary
JingleNegotiator()
          Default constructor.
JingleNegotiator(JingleSession session)
          Default constructor with a XMPPConnection
 
Method Summary
 void addExpectedId(java.lang.String id)
          Add expected ID
 void addListener(JingleListener li)
          Add a Jingle session listener to listen to incoming session requests.
 void close()
          Close the negotiation.
abstract  java.util.List<IQ> dispatchIncomingPacket(IQ iq, java.lang.String id)
          Dispatch an incoming packet.
 XMPPConnection getConnection()
           
 JingleNegotiatorState getNegotiatorState()
           
 JingleSession getSession()
          Get the XMPP connection associated with this negotiation.
 boolean isExpectedId(java.lang.String id)
          Check if the passed ID is the expected ID
 boolean isStarted()
           
 void removeExpectedId(java.lang.String id)
          Remove and expected ID
 void removeListener(JingleListener li)
          Removes a Jingle session listener.
 void setNegotiatorState(JingleNegotiatorState stateIs)
           
 void setSession(JingleSession session)
          Set the XMPP connection associated.
 void start()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JingleNegotiator

public JingleNegotiator()
Default constructor.


JingleNegotiator

public JingleNegotiator(JingleSession session)
Default constructor with a XMPPConnection

Parameters:
connection - the connection associated
Method Detail

getNegotiatorState

public JingleNegotiatorState getNegotiatorState()

setNegotiatorState

public void setNegotiatorState(JingleNegotiatorState stateIs)

getConnection

public XMPPConnection getConnection()

getSession

public JingleSession getSession()
Get the XMPP connection associated with this negotiation.

Returns:
the connection

setSession

public void setSession(JingleSession session)
Set the XMPP connection associated.

Parameters:
connection - the connection to set

addExpectedId

public void addExpectedId(java.lang.String id)
Add expected ID

Parameters:
id -

isExpectedId

public boolean isExpectedId(java.lang.String id)
Check if the passed ID is the expected ID

Parameters:
id -
Returns:

removeExpectedId

public void removeExpectedId(java.lang.String id)
Remove and expected ID

Parameters:
id -

addListener

public void addListener(JingleListener li)
Add a Jingle session listener to listen to incoming session requests.

Parameters:
li - The listener
See Also:
org.jivesoftware.smackx.jingle.listeners.JingleListener

removeListener

public void removeListener(JingleListener li)
Removes a Jingle session listener.

Parameters:
li - The jingle session listener to be removed
See Also:
org.jivesoftware.smackx.jingle.listeners.JingleListener

dispatchIncomingPacket

public abstract java.util.List<IQ> dispatchIncomingPacket(IQ iq,
                                                          java.lang.String id)
                                                   throws XMPPException
Dispatch an incoming packet. The negotiators form a tree relationship that roughly matches the Jingle packet format: JingleSession Content Negotiator Media Negotiator Transport Negotiator Content Negotiator Media Negotiator Transport Negotiator This way, each segment of a Jingle packet has a corresponding negotiator that know how to deal with that part of the Jingle packet. It also allows us to support Jingle packets of arbitraty complexity. Each parent calls dispatchIncomingPacket for each of its children. The children then pass back a List<> of results that will get sent when we reach the top level negotiator (JingleSession).

Parameters:
iq - the packet received
id - the ID of the response that will be sent
Returns:
the new packet to send (either a Jingle or an IQ error).
Throws:
XMPPException

start

public void start()

isStarted

public boolean isStarted()

close

public void close()
Close the negotiation.