From d7a8aafba20e3201c84ad0ab9d0cd201b8611957 Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Tue, 13 Mar 2007 17:30:58 +0000 Subject: [PATCH] Candidate Class Fixes git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7499 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/jingle/nat/ICECandidate.java | 36 +++++++++++++++---- .../smackx/jingle/nat/TransportCandidate.java | 5 +++ .../jingle/nat/TransportNegotiator.java | 5 +-- 3 files changed, 38 insertions(+), 8 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 94876f2ab..4c3704528 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java @@ -270,12 +270,6 @@ public class ICECandidate extends TransportCandidate implements Comparable { 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); - } - } } } }; @@ -308,6 +302,13 @@ 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 @@ -382,6 +383,29 @@ public class ICECandidate extends TransportCandidate implements Comparable { else if (!getUsername().equals(other.getUsername())) { return false; } + + if (getIp() == null) { + if (other.getIp() != null) { + return false; + } + } + else if (!getIp().equals(other.getIp())) { + return false; + } + + if (getPort() != other.getPort()) { + return false; + } + + if (getType() == null) { + if (other.getType() != null) { + return false; + } + } + else if (!getType().equals(other.getType())) { + return false; + } + return true; } 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 4766e24c6..c337c0fdc 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java @@ -353,6 +353,11 @@ public abstract class TransportCandidate { else if (!getIp().equals(other.getIp())) { return false; } + + if (getPort() != other.getPort()) { + return false; + } + if (getName() == null) { if (other.getName() != null) { return false; diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java index 091f4b25a..1896e4252 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java @@ -147,7 +147,8 @@ public abstract class TransportNegotiator extends JingleNegotiator { throws XMPPException { for (int i = 0; i < resolver.getCandidateCount(); i++) { //TODO FIX The EQUAL Sentence - if (resolver.getCandidate(i).getIp().equals(bestLocalCandidate.getIp())) { + if (resolver.getCandidate(i).getIp().equals(bestLocalCandidate.getIp()) + && resolver.getCandidate(i).getPort() == bestLocalCandidate.getPort()) { acceptedLocalCandidate = resolver.getCandidate(i); return; } @@ -384,7 +385,7 @@ public abstract class TransportNegotiator extends JingleNegotiator { // Add the candidate to the list if (remoteCandidate != null) { synchronized (validRemoteCandidates) { - System.out.println("ADDED Valid Cand: " + remoteCandidate.getIp()); + System.out.println("ADDED Valid Cand: " + remoteCandidate.getIp() + ":" + remoteCandidate.getPort()); validRemoteCandidates.add(remoteCandidate); } }