Class JingleSession

java.lang.Object
org.jivesoftware.smackx.jingleold.JingleNegotiator
org.jivesoftware.smackx.jingleold.JingleSession
All Implemented Interfaces:
MediaReceivedListener

public final class JingleSession extends JingleNegotiator implements MediaReceivedListener
An abstract Jingle session. This class contains some basic properties of every Jingle session. However, the concrete implementation can be found in subclasses.
  • Constructor Details

    • JingleSession

      public JingleSession(org.jivesoftware.smack.XMPPConnection conn, org.jxmpp.jid.Jid initiator, org.jxmpp.jid.Jid responder, String sessionid, List<JingleMediaManager> jingleMediaManagers)
      Full featured JingleSession constructor.
      Parameters:
      conn - TODO javadoc me please the XMPPConnection which is used
      initiator - TODO javadoc me please the initiator JID
      responder - TODO javadoc me please the responder JID
      sessionid - TODO javadoc me please the session ID
      jingleMediaManagers - TODO javadoc me please the jingleMediaManager
    • JingleSession

      public JingleSession(org.jivesoftware.smack.XMPPConnection conn, JingleSessionRequest request, org.jxmpp.jid.Jid initiator, org.jxmpp.jid.Jid responder, List<JingleMediaManager> jingleMediaManagers)
      JingleSession constructor (for an outgoing Jingle session).
      Parameters:
      conn - Connection
      request - the request.
      initiator - the initiator JID
      responder - the responder JID
      jingleMediaManagers - the jingleMediaManager
  • Method Details

    • getInitiator

      public org.jxmpp.jid.Jid getInitiator()
      Get the session initiator.
      Returns:
      the initiator
    • getConnection

      public org.jivesoftware.smack.XMPPConnection getConnection()
      Overrides:
      getConnection in class JingleNegotiator
    • setInitiator

      public void setInitiator(org.jxmpp.jid.Jid initiator)
      Set the session initiator.
      Parameters:
      initiator - TODO javadoc me please the initiator to set
    • getMediaManagers

      public List<JingleMediaManager> getMediaManagers()
      Get the Media Manager of this Jingle Session.
      Returns:
      the JingleMediaManagers
    • setMediaManagers

      public void setMediaManagers(List<JingleMediaManager> jingleMediaManagers)
      Set the Media Manager of this Jingle Session.
      Parameters:
      jingleMediaManagers - TODO javadoc me please
    • getResponder

      public org.jxmpp.jid.Jid getResponder()
      Get the session responder.
      Returns:
      the responder
    • setResponder

      public void setResponder(org.jxmpp.jid.Jid responder)
      Set the session responder.
      Parameters:
      responder - TODO javadoc me please the receptor to set
    • getSid

      public String getSid()
      Get the session ID.
      Returns:
      the sid
    • setSessionState

      public void setSessionState(JingleSessionState stateIs)
      Validate the state changes.
      Parameters:
      stateIs - the jingle session state.
    • getSessionState

      public JingleSessionState getSessionState()
    • isFullyEstablished

      public boolean isFullyEstablished()
      Return true if all of the media managers have finished.
      Returns:
      true if fully established.
    • receivePacketAndRespond

      public void receivePacketAndRespond(org.jivesoftware.smack.packet.IQ iq) throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedException
      Process and respond to an incoming packet. This method is called from the stanza listener dispatcher when a new stanza has arrived. The method is responsible for recognizing the stanza type and, depending on the current state, delivering it to the right event handler and wait for a response. The response will be another Jingle stanza that will be sent to the other end point.
      Parameters:
      iq - TODO javadoc me please the stanza received
      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.
    • dispatchIncomingPacket

      public List<org.jivesoftware.smack.packet.IQ> dispatchIncomingPacket(org.jivesoftware.smack.packet.IQ iq, String id) throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException, InterruptedException
      Dispatch an incoming packet. The method is responsible for recognizing the stanza type and, depending on the current state, delivering the stanza to the right event handler and wait for a response.
      Specified by:
      dispatchIncomingPacket in class JingleNegotiator
      Parameters:
      iq - TODO javadoc me please the stanza received
      id - the ID of the response that will be sent
      Returns:
      the new Jingle stanza to send.
      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.
    • addContentNegotiator

      public void addContentNegotiator(ContentNegotiator inContentNegotiator)
      Add a new content negotiator on behalf of a <content/> section received.
      Parameters:
      inContentNegotiator - the content negotiator.
    • sendStanza

      public void sendStanza(org.jivesoftware.smack.packet.IQ iq) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Throws:
      org.jivesoftware.smack.SmackException.NotConnectedException
      InterruptedException
    • sendFormattedJingle

      public Jingle sendFormattedJingle(Jingle jout) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Complete and send a packet. Complete all the null fields in a Jingle response, using the session information we have.
      Parameters:
      jout - the Jingle stanza we want to complete and send
      Returns:
      the Jingle stanza.
      Throws:
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • sendFormattedJingle

      public Jingle sendFormattedJingle(org.jivesoftware.smack.packet.IQ iq, Jingle jout) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Complete and send a packet. Complete all the null fields in a Jingle response, using the session information we have or some info from the incoming packet.
      Parameters:
      iq - The Jingle stanza we are responding to
      jout - the Jingle stanza we want to complete and send
      Returns:
      the Jingle stanza.
      Throws:
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • createAck

      public org.jivesoftware.smack.packet.IQ createAck(org.jivesoftware.smack.packet.IQ iq)
      Acknowledge a IQ packet.
      Parameters:
      iq - The IQ to acknowledge.
      Returns:
      the ack IQ.
    • hashCode

      public int hashCode()
      Send a content info message.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getInstanceFor

      public static JingleSession getInstanceFor(org.jivesoftware.smack.XMPPConnection con)
      Returns the JingleSession related to a particular connection.
      Parameters:
      con - TODO javadoc me please A XMPP connection
      Returns:
      a Jingle session
    • addMediaListener

      public void addMediaListener(JingleMediaListener li)
      Add a listener for jmf negotiation events.
      Parameters:
      li - TODO javadoc me please The listener
    • removeMediaListener

      public void removeMediaListener(JingleMediaListener li)
      Remove a listener for jmf negotiation events.
      Parameters:
      li - TODO javadoc me please The listener
    • addTransportListener

      public void addTransportListener(JingleTransportListener li)
      Add a listener for transport negotiation events.
      Parameters:
      li - TODO javadoc me please The listener
    • removeTransportListener

      public void removeTransportListener(JingleTransportListener li)
      Remove a listener for transport negotiation events.
      Parameters:
      li - TODO javadoc me please The listener
    • setupListeners

      public void setupListeners()
      Setup the listeners that act on events coming from the lower level negotiators.
    • terminate

      public void terminate() throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Terminates the session with default reason.
      Throws:
      org.jivesoftware.smack.XMPPException - if an XMPP protocol error was received.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • terminate

      public void terminate(String reason) throws org.jivesoftware.smack.XMPPException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Terminates the session with a custom reason.
      Parameters:
      reason - the reason.
      Throws:
      org.jivesoftware.smack.XMPPException - if an XMPP protocol error was received.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.
    • close

      public void close()
      Terminate negotiations.
      Overrides:
      close in class JingleNegotiator
    • isClosed

      public boolean isClosed()
    • createJingleError

      public org.jivesoftware.smack.packet.IQ createJingleError(org.jivesoftware.smack.packet.IQ iq, JingleError jingleError)
      Complete and send an error. Complete all the null fields in an IQ error response, using the session information we have or some info from the incoming packet.
      Parameters:
      iq - The Jingle stanza we are responding to
      jingleError - the IQ stanza we want to complete and send
      Returns:
      the jingle error IQ.
    • mediaReceived

      public void mediaReceived(String participant)
      Called when new Media is received.
      Specified by:
      mediaReceived in interface MediaReceivedListener
      Parameters:
      participant - the participant.
    • startOutgoing

      public void startOutgoing() throws IllegalStateException, org.jivesoftware.smack.SmackException, InterruptedException
      This is the starting point for initiating a new session.
      Throws:
      IllegalStateException - if an illegal state was encountered
      org.jivesoftware.smack.SmackException - if Smack detected an exceptional situation.
      InterruptedException - if the calling thread was interrupted.
    • startIncoming

      public void startIncoming()
      This is the starting point for responding to a new session.
    • doStart

      protected void doStart()
      Description copied from class: JingleNegotiator
      Each of the negotiators has their individual behavior when they start.
      Specified by:
      doStart in class JingleNegotiator
    • addJingleMediaSession

      public void addJingleMediaSession(String mediaManagerName, JingleMediaSession mediaSession)
      The jingle session may have one or more media managers that are trying to establish media sessions. When the media manager succeeds in creating a media session is registers it with the session by the media manager's static name. This routine is where the media manager does the registering.
      Parameters:
      mediaManagerName - the name of the media manager.
      mediaSession - the jingle media session.
    • getMediaSession

      public JingleMediaSession getMediaSession(String mediaManagerName)
      The jingle session may have one or more media managers that are trying to establish media sessions. When the media manager succeeds in creating a media session is registers it with the session by the media manager's static name. This routine is where other objects can access the registered media sessions. NB: If the media manager has not succeeded in establishing a media session then this could return null.
      Parameters:
      mediaManagerName - the name of the media manager.
      Returns:
      the jingle media session.