mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-23 06:42:05 +01:00
More Refactoring in Negotiation Speed
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7364 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
3c455c8367
commit
a616e34bd7
4 changed files with 42 additions and 26 deletions
|
@ -360,7 +360,7 @@ public abstract class JingleNegotiator {
|
|||
}
|
||||
|
||||
public Jingle eventTerminate(Jingle jin) throws XMPPException {
|
||||
if (neg != null) {
|
||||
if (neg != null && !neg.invalidState()) {
|
||||
neg.close();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -547,7 +547,7 @@ public abstract class JingleSession extends JingleNegotiator {
|
|||
* @param iq The Jingle packet we are responing to
|
||||
* @param error the IQ packet we want to complete and send
|
||||
*/
|
||||
protected IQ sendFormattedError(IQ iq, JingleError error) {
|
||||
public IQ sendFormattedError(IQ iq, JingleError error) {
|
||||
IQ perror = null;
|
||||
if (error != null) {
|
||||
perror = createIQ(getSid(), iq.getFrom(), iq.getTo(), IQ.Type.ERROR);
|
||||
|
@ -1121,6 +1121,7 @@ public abstract class JingleSession extends JingleNegotiator {
|
|||
* @throws XMPPException
|
||||
*/
|
||||
public void terminate() throws XMPPException {
|
||||
if (isClosed()) return;
|
||||
System.out.println("State: " + this.getState());
|
||||
Jingle result = null;
|
||||
Jingle jout = new Jingle(Jingle.Action.SESSIONTERMINATE);
|
||||
|
@ -1133,6 +1134,7 @@ public abstract class JingleSession extends JingleNegotiator {
|
|||
* Terminate negotiations.
|
||||
*/
|
||||
public void close() {
|
||||
if (isClosed()) return;
|
||||
destroyMediaNeg();
|
||||
destroyTransportNeg();
|
||||
removePacketListener();
|
||||
|
|
|
@ -277,9 +277,13 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
public void run() {
|
||||
|
||||
// Sleep for some time, waiting for the candidates checks
|
||||
|
||||
int totalTime= (CANDIDATES_ACCEPT_PERIOD + (TransportResolver.CHECK_TIMEOUT * (resolver.getCandidatesList().size()+1)));
|
||||
int tries = (int)Math.ceil(totalTime/1000);
|
||||
|
||||
for (int i = 0; i < tries; i++) {
|
||||
try {
|
||||
Thread.sleep(CANDIDATES_ACCEPT_PERIOD
|
||||
+ TransportResolver.CHECK_TIMEOUT);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -300,6 +304,16 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
|
||||
if (isEstablished()) {
|
||||
setState(active);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getState() == null || !getState().equals(active)) {
|
||||
try {
|
||||
session.terminate();
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,10 +129,10 @@ public class JingleMediaTest extends SmackTestCase {
|
|||
x1, new BasicTransportManager());
|
||||
|
||||
MultiMediaManager jingleMediaManager0 = new MultiMediaManager();
|
||||
// jingleMediaManager0.addMediaManager(new SpeexMediaManager());
|
||||
jingleMediaManager0.addMediaManager(new SpeexMediaManager());
|
||||
jingleMediaManager0.addMediaManager(new JmfMediaManager());
|
||||
MultiMediaManager jingleMediaManager1 = new MultiMediaManager();
|
||||
// jingleMediaManager1.addMediaManager(new JmfMediaManager());
|
||||
jingleMediaManager1.addMediaManager(new JmfMediaManager());
|
||||
jingleMediaManager1.addMediaManager(new SpeexMediaManager());
|
||||
|
||||
jm0.setMediaManager(jingleMediaManager0);
|
||||
|
|
Loading…
Reference in a new issue