From 4e165d5f4e3f26243b972d27c13accb7212950c6 Mon Sep 17 00:00:00 2001
From: "lubomir.marinov"
Date: Fri, 26 Feb 2010 12:08:46 +0000
Subject: [PATCH] Adds getSocket() to Candidate instead of having it just in
HostCandidate.
---
src/org/ice4j/ice/Candidate.java | 11 ++++++-
src/org/ice4j/ice/HostCandidate.java | 8 +++--
.../ice4j/ice/ServerReflexiveCandidate.java | 33 +++++++++++++++----
3 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/src/org/ice4j/ice/Candidate.java b/src/org/ice4j/ice/Candidate.java
index ecca46e..2245b77 100644
--- a/src/org/ice4j/ice/Candidate.java
+++ b/src/org/ice4j/ice/Candidate.java
@@ -24,8 +24,9 @@ import org.ice4j.*;
*
*
* @author Emil Ivov
+ * @author Lubomir Marinov
*/
-public class Candidate
+public abstract class Candidate
{
/**
* The transport address represented by this candidate.
@@ -140,6 +141,14 @@ public class Candidate
this.candidateType = type;
}
+ /**
+ * Gets the DatagramSocket associated with this Candidate.
+ *
+ * @return the DatagramSocket associated with this
+ * Candidate
+ */
+ public abstract DatagramSocket getSocket();
+
/**
* Returns the type of this candidate which should be an instance of the
* {@link CandidateType} enumeration.
diff --git a/src/org/ice4j/ice/HostCandidate.java b/src/org/ice4j/ice/HostCandidate.java
index 99c914a..b83f924 100644
--- a/src/org/ice4j/ice/HostCandidate.java
+++ b/src/org/ice4j/ice/HostCandidate.java
@@ -32,7 +32,7 @@ public class HostCandidate extends Candidate
* If this is a local candidate the field contains the socket that is
* actually associated with the candidate.
*/
- private DatagramSocket socket = null;
+ private final DatagramSocket socket;
/**
* Creates a HostCandidate for the specified transport address.
@@ -55,9 +55,11 @@ public class HostCandidate extends Candidate
}
/**
- * Returns the DatagramSocket associated with this candidate.
+ * Gets the DatagramSocket associated with this Candidate.
*
- * @return the DatagramSocket associated with this candidate.
+ * @return the DatagramSocket associated with this
+ * Candidate
+ * @see Candidate#getSocket()
*/
public DatagramSocket getSocket()
{
diff --git a/src/org/ice4j/ice/ServerReflexiveCandidate.java b/src/org/ice4j/ice/ServerReflexiveCandidate.java
index dc8aac2..0509fd9 100644
--- a/src/org/ice4j/ice/ServerReflexiveCandidate.java
+++ b/src/org/ice4j/ice/ServerReflexiveCandidate.java
@@ -1,16 +1,25 @@
+/*
+ * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
+ * Maintained by the SIP Communicator community (http://sip-communicator.org).
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package org.ice4j.ice;
+import java.net.*;
+
import org.ice4j.*;
/**
* ServerReflexiveCandidates are candidates whose IP address and port
- * are a binding allocated by a NAT for an agent when it sent a packet through
- * the NAT to a server. ServerReflexiveCandidates can be learned by
- * STUN servers using the Binding Request, or TURN servers, which provides
- * both a Relayed and Server Reflexive candidate.
+ * are a binding allocated by a NAT for an agent when it sent a packet through
+ * the NAT to a server. ServerReflexiveCandidates can be learned by
+ * STUN servers using the Binding Request, or TURN servers, which provides both
+ * a Relayed and Server Reflexive candidate.
*
- * This class does not contain a socket itself and in order to send bytes
- * over the network, one has to retrieve the socket of its basis.
+ * This class does not contain a socket itself and in order to send bytes over
+ * the network, one has to retrieve the socket of its base.
*
*
* @author Emil Ivov
@@ -40,4 +49,16 @@ public class ServerReflexiveCandidate extends Candidate
setBase(base);
setStunServerAddress(stunSrvrAddr);
}
+
+ /**
+ * Gets the DatagramSocket associated with this Candidate.
+ *
+ * @return the DatagramSocket associated with this
+ * Candidate
+ * @see Candidate#getSocket()
+ */
+ public DatagramSocket getSocket()
+ {
+ return getBase().getSocket();
+ }
}