From 1983632730222629037e3a88de5ca273c02dd765 Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Mon, 12 Mar 2007 19:46:03 +0000 Subject: [PATCH] ECHO Fixes git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7475 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/jingle/nat/ICECandidate.java | 14 +++++++------- .../smackx/jingle/nat/TransportCandidate.java | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java index 865cf6574..e82f0fd70 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java @@ -269,6 +269,13 @@ public class ICECandidate extends TransportCandidate implements Comparable { public void testFinished(TestResult testResult, TransportCandidate candidate) { if (testResult.isReachable() && checkingCandidate.equals(candidate)) { result.setResult(true); + System.out.println("RESULT>>>OK:" + candidate.getIp() + ":" + candidate.getPort()); + for (TransportCandidate c : localCandidates) { + CandidateEcho echo = candidate.getCandidateEcho(); + if (echo != null) { + echo.removeResultListener(this); + } + } } } }; @@ -301,13 +308,6 @@ public class ICECandidate extends TransportCandidate implements Comparable { e.printStackTrace(); } - for (TransportCandidate candidate : localCandidates) { - CandidateEcho echo = candidate.getCandidateEcho(); - if (echo != null) { - echo.removeResultListener(resultListener); - } - } - triggerCandidateChecked(result.isReachable()); //TODO candidate is being checked trigger diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java index e48522c49..fee70a667 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java @@ -705,7 +705,7 @@ public abstract class TransportCandidate { //System.out.println("ECHO Packet Received in: " + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort() + " From: " + packet.getAddress().getHostAddress() + ":" + packet.getPort()); - boolean reply = false; + boolean accept = false; ByteBuffer buf = ByteBuffer.wrap(packet.getData()); byte[] content = new byte[packet.getLength()]; @@ -714,8 +714,8 @@ public abstract class TransportCandidate { packet.setData(content); for (DatagramListener listener : listeners) { - reply = listener.datagramReceived(packet); - if (reply) break; + accept = listener.datagramReceived(packet); + if (accept) break; } long delay = 200 / tries / 2; @@ -728,7 +728,7 @@ public abstract class TransportCandidate { String ip = address[0]; String port = address[1]; - if (pass.equals(candidate.getPassword())) { + if (pass.equals(candidate.getPassword()) && !accept) { byte[] cont = null; try {