1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 22:12:05 +01:00

Terminate a session instead Decline with an Error packet

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7063 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Thiago Camargo 2007-02-09 03:49:43 +00:00 committed by thiago
parent 5102acc985
commit 877afcd3ba
3 changed files with 22 additions and 18 deletions

View file

@ -174,7 +174,7 @@ public class IncomingJingleSession extends JingleSession {
* *
* @return * @return
*/ */
JingleSessionRequest getInitialSessionRequest() { public JingleSessionRequest getInitialSessionRequest() {
return initialSessionRequest; return initialSessionRequest;
} }
@ -183,7 +183,7 @@ public class IncomingJingleSession extends JingleSession {
* *
* @param initialRequest the initial Jingle packet * @param initialRequest the initial Jingle packet
*/ */
void setInitialSessionRequest(JingleSessionRequest initialRequest) { public void setInitialSessionRequest(JingleSessionRequest initialRequest) {
this.initialSessionRequest = initialRequest; this.initialSessionRequest = initialRequest;
} }
@ -227,7 +227,7 @@ public class IncomingJingleSession extends JingleSession {
* "Pending" state: we are waiting for the transport and content * "Pending" state: we are waiting for the transport and content
* negotiators. * negotiators.
*/ */
private class Pending extends JingleNegotiator.State { public class Pending extends JingleNegotiator.State {
JingleMediaListener jingleMediaListener; JingleMediaListener jingleMediaListener;
@ -373,7 +373,7 @@ public class IncomingJingleSession extends JingleSession {
/** /**
* "Active" state: we have an agreement about the session. * "Active" state: we have an agreement about the session.
*/ */
private class Active extends JingleNegotiator.State { public class Active extends JingleNegotiator.State {
public Active(JingleNegotiator neg) { public Active(JingleNegotiator neg) {
super(neg); super(neg);
} }

View file

@ -118,6 +118,8 @@ public abstract class JingleSession extends JingleNegotiator {
static int ccc = 0; static int ccc = 0;
private boolean closed = false;
/** /**
* Full featured JingleSession constructor * Full featured JingleSession constructor
* *
@ -605,7 +607,7 @@ public abstract class JingleSession extends JingleNegotiator {
* *
* @param iq The IQ to acknowledge * @param iq The IQ to acknowledge
*/ */
private IQ sendAck(IQ iq) { public IQ sendAck(IQ iq) {
IQ result = null; IQ result = null;
if (iq != null) { if (iq != null) {
@ -1074,7 +1076,6 @@ public abstract class JingleSession extends JingleNegotiator {
*/ */
public void terminate() throws XMPPException { public void terminate() throws XMPPException {
System.out.println("State: " + this.getState()); System.out.println("State: " + this.getState());
if (!invalidState()) {
Jingle result = null; Jingle result = null;
Jingle jout = new Jingle(Jingle.Action.SESSIONTERMINATE); Jingle jout = new Jingle(Jingle.Action.SESSIONTERMINATE);
jout.setType(IQ.Type.SET); jout.setType(IQ.Type.SET);
@ -1082,10 +1083,6 @@ public abstract class JingleSession extends JingleNegotiator {
triggerSessionClosed("Closed Locally"); triggerSessionClosed("Closed Locally");
close(); close();
} }
else {
throw new IllegalStateException("Session Not Started");
}
}
/** /**
* Terminate negotiations. * Terminate negotiations.
@ -1095,9 +1092,14 @@ public abstract class JingleSession extends JingleNegotiator {
destroyTransportNeg(); destroyTransportNeg();
removePacketListener(); removePacketListener();
System.out.println("Negociation Closed"); System.out.println("Negociation Closed");
closed=true;
super.close(); super.close();
} }
public boolean isClosed() {
return closed;
}
// Packet and error creation // Packet and error creation
/** /**
@ -1142,7 +1144,7 @@ public abstract class JingleSession extends JingleNegotiator {
XMPPError error = new XMPPError(new XMPPError.Condition(errStr)); XMPPError error = new XMPPError(new XMPPError.Condition(errStr));
iqError.setError(error); iqError.setError(error);
System.out.println(iqError.toXML()); System.out.println("Created Error Packet:" + iqError.toXML());
return iqError; return iqError;
} }

View file

@ -8,7 +8,7 @@ import java.util.List;
/** /**
* A Jingle session request. * A Jingle session request.
* * <p/>
* This class is a facade of a received Jingle request. The user can have direct * This class is a facade of a received Jingle request. The user can have direct
* access to the Jingle packet (<i>JingleSessionRequest.getJingle() </i>) of * access to the Jingle packet (<i>JingleSessionRequest.getJingle() </i>) of
* the request or can use the convencience methods provided by this class. * the request or can use the convencience methods provided by this class.
@ -76,6 +76,8 @@ public class JingleSessionRequest {
session = manager.createIncomingJingleSession(this, session = manager.createIncomingJingleSession(this,
pts); pts);
session.setInitialSessionRequest(this); session.setInitialSessionRequest(this);
// Acknowledge the IQ reception
session.sendAck(this.getJingle());
} }
return session; return session;
} }