Class JingleSession
java.lang.Object
org.jivesoftware.smackx.jingleold.JingleNegotiator
org.jivesoftware.smackx.jingleold.JingleSession
- All Implemented Interfaces:
MediaReceivedListener
An abstract Jingle session. This class contains some basic properties of
every Jingle session. However, the concrete implementation can be found in
subclasses.
-
Field Summary
Fields inherited from class org.jivesoftware.smackx.jingleold.JingleNegotiator
session
-
Constructor Summary
ConstructorDescriptionJingleSession
(XMPPConnection conn, JingleSessionRequest request, Jid initiator, Jid responder, List<JingleMediaManager> jingleMediaManagers) JingleSession constructor (for an outgoing Jingle session).JingleSession
(XMPPConnection conn, Jid initiator, Jid responder, String sessionid, List<JingleMediaManager> jingleMediaManagers) Full featured JingleSession constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addContentNegotiator
(ContentNegotiator inContentNegotiator) Add a new content negotiator on behalf of a <content/> section received.void
addJingleMediaSession
(String mediaManagerName, JingleMediaSession mediaSession) The jingle session may have one or more media managers that are trying to establish media sessions.void
Add a listener for jmf negotiation events.void
Add a listener for transport negotiation events.void
close()
Terminate negotiations.Acknowledge a IQ packet.createJingleError
(IQ iq, JingleError jingleError) Complete and send an error.dispatchIncomingPacket
(IQ iq, String id) Dispatch an incoming packet.protected void
doStart()
Each of the negotiators has their individual behavior when they start.boolean
Get the session initiator.static JingleSession
Returns the JingleSession related to a particular connection.Get the Media Manager of this Jingle Session.getMediaSession
(String mediaManagerName) The jingle session may have one or more media managers that are trying to establish media sessions.Get the session responder.getSid()
Get the session ID.int
hashCode()
Send a content info message.boolean
isClosed()
boolean
Return true if all of the media managers have finished.void
mediaReceived
(String participant) Called when new Media is received.void
Process and respond to an incoming packet.void
Remove a listener for jmf negotiation events.void
Remove a listener for transport negotiation events.sendFormattedJingle
(IQ iq, Jingle jout) Complete and send a packet.sendFormattedJingle
(Jingle jout) Complete and send a packet.void
sendStanza
(IQ iq) void
setInitiator
(Jid initiator) Set the session initiator.void
setMediaManagers
(List<JingleMediaManager> jingleMediaManagers) Set the Media Manager of this Jingle Session.void
setResponder
(Jid responder) Set the session responder.void
setSessionState
(JingleSessionState stateIs) Validate the state changes.void
Setup the listeners that act on events coming from the lower level negotiators.void
This is the starting point for responding to a new session.void
This is the starting point for initiating a new session.void
Terminates the session with default reason.void
Terminates the session with a custom reason.Methods inherited from class org.jivesoftware.smackx.jingleold.JingleNegotiator
addExpectedId, addListener, getListenersList, getNegotiatorState, getSession, isExpectedId, isStarted, removeExpectedId, removeListener, setNegotiatorState, setSession, start
-
Constructor Details
-
JingleSession
public JingleSession(XMPPConnection conn, Jid initiator, Jid responder, String sessionid, List<JingleMediaManager> jingleMediaManagers) Full featured JingleSession constructor.- Parameters:
conn
- TODO javadoc me please the XMPPConnection which is usedinitiator
- TODO javadoc me please the initiator JIDresponder
- TODO javadoc me please the responder JIDsessionid
- TODO javadoc me please the session IDjingleMediaManagers
- TODO javadoc me please the jingleMediaManager
-
JingleSession
public JingleSession(XMPPConnection conn, JingleSessionRequest request, Jid initiator, Jid responder, List<JingleMediaManager> jingleMediaManagers) JingleSession constructor (for an outgoing Jingle session).- Parameters:
conn
- Connectionrequest
- the request.initiator
- the initiator JIDresponder
- the responder JIDjingleMediaManagers
- the jingleMediaManager
-
-
Method Details
-
getInitiator
Get the session initiator.- Returns:
- the initiator
-
getConnection
- Overrides:
getConnection
in classJingleNegotiator
-
setInitiator
Set the session initiator.- Parameters:
initiator
- TODO javadoc me please the initiator to set
-
getMediaManagers
Get the Media Manager of this Jingle Session.- Returns:
- the JingleMediaManagers
-
setMediaManagers
Set the Media Manager of this Jingle Session.- Parameters:
jingleMediaManagers
- TODO javadoc me please
-
getResponder
Get the session responder.- Returns:
- the responder
-
setResponder
Set the session responder.- Parameters:
responder
- TODO javadoc me please the receptor to set
-
getSid
Get the session ID.- Returns:
- the sid
-
setSessionState
Validate the state changes.- Parameters:
stateIs
- the jingle session state.
-
getSessionState
-
isFullyEstablished
Return true if all of the media managers have finished.- Returns:
true
if fully established.
-
receivePacketAndRespond
public void receivePacketAndRespond(IQ iq) throws XMPPException, 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:
XMPPException
- if an XMPP protocol error was received.SmackException
- if Smack detected an exceptional situation.InterruptedException
- if the calling thread was interrupted.
-
dispatchIncomingPacket
public List<IQ> dispatchIncomingPacket(IQ iq, String id) throws XMPPException, 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 classJingleNegotiator
- Parameters:
iq
- TODO javadoc me please the stanza receivedid
- the ID of the response that will be sent- Returns:
- the new Jingle stanza to send.
- Throws:
XMPPException
- if an XMPP protocol error was received.SmackException
- if Smack detected an exceptional situation.InterruptedException
- if the calling thread was interrupted.
-
addContentNegotiator
Add a new content negotiator on behalf of a <content/> section received.- Parameters:
inContentNegotiator
- the content negotiator.
-
sendStanza
-
sendFormattedJingle
public Jingle sendFormattedJingle(Jingle jout) throws 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:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
sendFormattedJingle
public Jingle sendFormattedJingle(IQ iq, Jingle jout) throws 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 tojout
- the Jingle stanza we want to complete and send- Returns:
- the Jingle stanza.
- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
createAck
Acknowledge a IQ packet.- Parameters:
iq
- The IQ to acknowledge.- Returns:
- the ack IQ.
-
hashCode
Send a content info message. -
equals
-
getInstanceFor
Returns the JingleSession related to a particular connection.- Parameters:
con
- TODO javadoc me please A XMPP connection- Returns:
- a Jingle session
-
addMediaListener
Add a listener for jmf negotiation events.- Parameters:
li
- TODO javadoc me please The listener
-
removeMediaListener
Remove a listener for jmf negotiation events.- Parameters:
li
- TODO javadoc me please The listener
-
addTransportListener
Add a listener for transport negotiation events.- Parameters:
li
- TODO javadoc me please The listener
-
removeTransportListener
Remove a listener for transport negotiation events.- Parameters:
li
- TODO javadoc me please The listener
-
setupListeners
Setup the listeners that act on events coming from the lower level negotiators. -
terminate
public void terminate() throws XMPPException, SmackException.NotConnectedException, InterruptedExceptionTerminates the session with default reason.- Throws:
XMPPException
- if an XMPP protocol error was received.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
terminate
public void terminate(String reason) throws XMPPException, SmackException.NotConnectedException, InterruptedException Terminates the session with a custom reason.- Parameters:
reason
- the reason.- Throws:
XMPPException
- if an XMPP protocol error was received.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
close
Terminate negotiations.- Overrides:
close
in classJingleNegotiator
-
isClosed
-
createJingleError
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 tojingleError
- the IQ stanza we want to complete and send- Returns:
- the jingle error IQ.
-
mediaReceived
Called when new Media is received.- Specified by:
mediaReceived
in interfaceMediaReceivedListener
- Parameters:
participant
- the participant.
-
startOutgoing
This is the starting point for initiating a new session.- Throws:
IllegalStateException
- if an illegal state was encounteredSmackException
- if Smack detected an exceptional situation.InterruptedException
- if the calling thread was interrupted.
-
startIncoming
This is the starting point for responding to a new session. -
doStart
Description copied from class:JingleNegotiator
Each of the negotiators has their individual behavior when they start.- Specified by:
doStart
in classJingleNegotiator
-
addJingleMediaSession
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
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.
-