mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 16:22:06 +01:00
Smack-261
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@10934 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
6b375b2e9f
commit
bc9f0179fa
8 changed files with 57 additions and 69 deletions
Binary file not shown.
|
@ -117,7 +117,7 @@ public class ContentNegotiator extends JingleNegotiator {
|
|||
/**
|
||||
* Called from above when starting a new session.
|
||||
*/
|
||||
public void start() {
|
||||
protected void doStart() {
|
||||
JingleContent result = new JingleContent(creator, name);
|
||||
|
||||
// result.setDescription(mediaNeg.start());
|
||||
|
|
|
@ -598,29 +598,4 @@ public class JingleManager implements JingleSessionListener {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject the session. If we don't want to accept the new session then we have to
|
||||
* result/ack the session-initiate and send a session-terminate.
|
||||
*
|
||||
* @param request the request to be rejected.
|
||||
*/
|
||||
protected void rejectIncomingJingleSession(JingleSessionRequest request) {
|
||||
|
||||
JingleSession session = getSession(request.getSessionID());
|
||||
if (session != null) {
|
||||
|
||||
// First send the result/Ack
|
||||
IQ result = session.createAck(request.getJingle());
|
||||
connection.sendPacket(result);
|
||||
|
||||
// Now send the session-terminate.
|
||||
try {
|
||||
session.terminate("Declined");
|
||||
} catch (XMPPException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,6 +55,8 @@ public abstract class JingleNegotiator {
|
|||
|
||||
private JingleNegotiatorState state;
|
||||
|
||||
private boolean isStarted;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
|
@ -234,6 +236,21 @@ public abstract class JingleNegotiator {
|
|||
*/
|
||||
public abstract List<IQ> dispatchIncomingPacket(IQ iq, String id) throws XMPPException;
|
||||
|
||||
|
||||
public void start() {
|
||||
isStarted = true;
|
||||
doStart();
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return isStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Each of the negotiators has their individual behavior when they start.
|
||||
*/
|
||||
protected abstract void doStart();
|
||||
|
||||
/**
|
||||
* Close the negotiation.
|
||||
*/
|
||||
|
|
|
@ -333,6 +333,13 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
// Each content negotiator may pass back a list of JingleContent for addition to the response packet.
|
||||
|
||||
for (ContentNegotiator contentNegotiator : contentNegotiators) {
|
||||
// If at this point the content negotiator isn't started, it's because we sent a session-init jingle
|
||||
// packet from startOutgoing() and we're waiting for the other side to let us know they're ready
|
||||
// to take jingle packets. (This packet might be a session-terminate, but that will get handled
|
||||
// later.
|
||||
if (!contentNegotiator.isStarted()) {
|
||||
contentNegotiator.start();
|
||||
}
|
||||
responses.addAll(contentNegotiator.dispatchIncomingPacket(iq, responseId));
|
||||
}
|
||||
|
||||
|
@ -400,7 +407,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
|
||||
// Depending on the state we're in we'll get different processing actions.
|
||||
// (See Design Patterns AKA GoF State behavioral pattern.)
|
||||
getSessionState().processJingle(this, jin, action);
|
||||
response = getSessionState().processJingle(this, jin, action);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,30 +436,6 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
public void sendPacket(IQ iq) {
|
||||
|
||||
if (iq instanceof Jingle) {
|
||||
// Jingle jingle = (Jingle) iq;
|
||||
//
|
||||
// JingleActionEnum action = jingle.getAction();
|
||||
//
|
||||
// switch (getSessionState()) {
|
||||
// case UNKNOWN:
|
||||
// sendUnknownStateAction(jingle, action);
|
||||
// break;
|
||||
//
|
||||
// case PENDING:
|
||||
// sendPendingStateAction(jingle, action);
|
||||
// break;
|
||||
//
|
||||
// case ACTIVE:
|
||||
// sendActiveStateAction(jingle, action);
|
||||
// break;
|
||||
//
|
||||
// case ENDED:
|
||||
// sendEndedStateAction(jingle, action);
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
sendFormattedJingle((Jingle) iq);
|
||||
|
||||
|
@ -1238,9 +1221,13 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
|
||||
// Give each of the content negotiators a chance to start
|
||||
// and return a portion of the structure to make the Jingle packet.
|
||||
for (ContentNegotiator contentNegotiator : contentNegotiators) {
|
||||
contentNegotiator.start();
|
||||
}
|
||||
|
||||
// Don't do this anymore. The problem is that the other side might not be ready.
|
||||
// Later when we receive our first jingle packet from the other side we'll fire-up the negotiators
|
||||
// before processing it. (See receivePacketAndRespond() above.
|
||||
// for (ContentNegotiator contentNegotiator : contentNegotiators) {
|
||||
// contentNegotiator.start();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1251,6 +1238,10 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
//updatePacketListener();
|
||||
}
|
||||
|
||||
protected void doStart() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* When we initiate a session we need to start a bunch of negotiators right after we receive the result
|
||||
* packet for our session-initiate. This is where we start them.
|
||||
|
|
|
@ -33,6 +33,8 @@ import org.jivesoftware.smackx.packet.Jingle;
|
|||
*/
|
||||
public class JingleSessionRequest {
|
||||
|
||||
private static final SmackLogger LOGGER = SmackLogger.getLogger(JingleSessionRequest.class);
|
||||
|
||||
private final Jingle jingle; // The Jingle packet
|
||||
|
||||
private final JingleManager manager; // The manager associated to this
|
||||
|
@ -121,8 +123,18 @@ public class JingleSessionRequest {
|
|||
* Rejects the session request.
|
||||
*/
|
||||
public synchronized void reject() {
|
||||
JingleSession session = null;
|
||||
synchronized (manager) {
|
||||
manager.rejectIncomingJingleSession(this);
|
||||
try {
|
||||
session = manager.createIncomingJingleSession(this);
|
||||
// Acknowledge the IQ reception
|
||||
session.setSid(this.getSessionID());
|
||||
//session.sendAck(this.getJingle());
|
||||
session.updatePacketListener();
|
||||
session.terminate("Declined");
|
||||
} catch (XMPPException e) {
|
||||
LOGGER.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -507,11 +507,8 @@ public class MediaNegotiator extends JingleNegotiator {
|
|||
* Called from above when starting a new session.
|
||||
* @return
|
||||
*/
|
||||
public void start() {
|
||||
//JingleDescription result = new JingleDescription.Audio();
|
||||
// result.addAudioPayloadTypes(localAudioPts);
|
||||
protected void doStart() {
|
||||
|
||||
// return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -142,8 +142,8 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
return;
|
||||
}
|
||||
}
|
||||
//LOGGER.debug("BEST: " + bestLocalCandidate.getIp());
|
||||
throw new XMPPException("Local transport candidate has not be offered.");
|
||||
LOGGER.debug("BEST: ip=" + bestLocalCandidate.getIp() + " port=" + bestLocalCandidate.getPort() + " has not been offered.");
|
||||
//throw new XMPPException("Local transport candidate has not be offered.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,9 +158,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
/**
|
||||
* Called from above to start the negotiator during a session-initiate.
|
||||
*/
|
||||
public void start() {
|
||||
|
||||
//JingleTransport result = new JingleTransport(getJingleTransport());
|
||||
protected void doStart() {
|
||||
|
||||
try {
|
||||
sendTransportCandidatesOffer();
|
||||
|
@ -170,8 +168,6 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue