mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-04 15:45:58 +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 {
|
public Jingle eventTerminate(Jingle jin) throws XMPPException {
|
||||||
if (neg != null) {
|
if (neg != null && !neg.invalidState()) {
|
||||||
neg.close();
|
neg.close();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -547,7 +547,7 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
* @param iq The Jingle packet we are responing to
|
* @param iq The Jingle packet we are responing to
|
||||||
* @param error the IQ packet we want to complete and send
|
* @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;
|
IQ perror = null;
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
perror = createIQ(getSid(), iq.getFrom(), iq.getTo(), IQ.Type.ERROR);
|
perror = createIQ(getSid(), iq.getFrom(), iq.getTo(), IQ.Type.ERROR);
|
||||||
|
@ -1121,6 +1121,7 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
* @throws XMPPException
|
* @throws XMPPException
|
||||||
*/
|
*/
|
||||||
public void terminate() throws XMPPException {
|
public void terminate() throws XMPPException {
|
||||||
|
if (isClosed()) return;
|
||||||
System.out.println("State: " + this.getState());
|
System.out.println("State: " + this.getState());
|
||||||
Jingle result = null;
|
Jingle result = null;
|
||||||
Jingle jout = new Jingle(Jingle.Action.SESSIONTERMINATE);
|
Jingle jout = new Jingle(Jingle.Action.SESSIONTERMINATE);
|
||||||
|
@ -1133,6 +1134,7 @@ public abstract class JingleSession extends JingleNegotiator {
|
||||||
* Terminate negotiations.
|
* Terminate negotiations.
|
||||||
*/
|
*/
|
||||||
public void close() {
|
public void close() {
|
||||||
|
if (isClosed()) return;
|
||||||
destroyMediaNeg();
|
destroyMediaNeg();
|
||||||
destroyTransportNeg();
|
destroyTransportNeg();
|
||||||
removePacketListener();
|
removePacketListener();
|
||||||
|
|
|
@ -277,9 +277,13 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// Sleep for some time, waiting for the candidates checks
|
// 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 {
|
try {
|
||||||
Thread.sleep(CANDIDATES_ACCEPT_PERIOD
|
Thread.sleep(1000);
|
||||||
+ TransportResolver.CHECK_TIMEOUT);
|
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -300,6 +304,16 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
||||||
|
|
||||||
if (isEstablished()) {
|
if (isEstablished()) {
|
||||||
setState(active);
|
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());
|
x1, new BasicTransportManager());
|
||||||
|
|
||||||
MultiMediaManager jingleMediaManager0 = new MultiMediaManager();
|
MultiMediaManager jingleMediaManager0 = new MultiMediaManager();
|
||||||
// jingleMediaManager0.addMediaManager(new SpeexMediaManager());
|
jingleMediaManager0.addMediaManager(new SpeexMediaManager());
|
||||||
jingleMediaManager0.addMediaManager(new JmfMediaManager());
|
jingleMediaManager0.addMediaManager(new JmfMediaManager());
|
||||||
MultiMediaManager jingleMediaManager1 = new MultiMediaManager();
|
MultiMediaManager jingleMediaManager1 = new MultiMediaManager();
|
||||||
// jingleMediaManager1.addMediaManager(new JmfMediaManager());
|
jingleMediaManager1.addMediaManager(new JmfMediaManager());
|
||||||
jingleMediaManager1.addMediaManager(new SpeexMediaManager());
|
jingleMediaManager1.addMediaManager(new SpeexMediaManager());
|
||||||
|
|
||||||
jm0.setMediaManager(jingleMediaManager0);
|
jm0.setMediaManager(jingleMediaManager0);
|
||||||
|
|
Loading…
Reference in a new issue