diff --git a/src/org/ice4j/ice/harvest/AbstractStunCandidateHarvester.java b/src/org/ice4j/ice/harvest/AbstractStunCandidateHarvester.java
index 788010e..3cde7fc 100644
--- a/src/org/ice4j/ice/harvest/AbstractStunCandidateHarvester.java
+++ b/src/org/ice4j/ice/harvest/AbstractStunCandidateHarvester.java
@@ -51,7 +51,7 @@ public abstract class AbstractStunCandidateHarvester
/**
* The stack to use for STUN communication.
*/
- private final StunStack stunStack = StunStack.getInstance();
+ protected final StunStack stunStack = StunStack.getInstance();
/**
* Creates a new STUN harvester that will be running against the specified
@@ -110,7 +110,7 @@ public abstract class AbstractStunCandidateHarvester
* @param base the HostCandidate that we should use as a base
* for the new ServerReflexiveCandidate.
*/
- protected void createServerReflexiveCandidate(Message response,
+ protected void createServerReflexiveCandidate(Message response,
HostCandidate base)
{
Attribute attribute
diff --git a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
index 120e6e1..bb14710 100644
--- a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
+++ b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
@@ -7,6 +7,10 @@
*/
package org.ice4j.ice.harvest;
+import java.net.*;
+import java.util.*;
+import java.util.logging.*;
+
import org.ice4j.*;
import org.ice4j.ice.*;
import org.ice4j.message.*;
@@ -23,6 +27,12 @@ import org.ice4j.socket.*;
public class StunCandidateHarvester
extends AbstractStunCandidateHarvester
{
+ /**
+ * The Logger used by the StunCandidateHarvester
+ * class and its instances for logging output.
+ */
+ private static final Logger logger
+ = Logger.getLogger(AbstractStunCandidateHarvester.class.getName());
/**
* The DatagramPacketFilter which accepts only STUN messages
@@ -32,6 +42,13 @@ public class StunCandidateHarvester
private static final StunDatagramPacketFilter stunDatagramPacketFilter
= new StunDatagramPacketFilter();
+ /**
+ * The list of candidates that this harvester has allocated and that it
+ * needs to keep alive.
+ */
+ private List allocatedCandidates
+ = new LinkedList();
+
/**
* Creates a new STUN harvester that will be running against the specified
* stunServer.
@@ -81,4 +98,30 @@ public class StunCandidateHarvester
{
return stunDatagramPacketFilter;
}
+
+ /**
+ * reSends a binding request to our stun server through the specified
+ * srflxCand candidate so that it would keep the potential NAT
+ * mapping valid.
+ *
+ * @param srflxCand the ServerReflexiveCandidate that we'd like to
+ * refresh and keep alive.
+ */
+ private void refreshCandidate(ServerReflexiveCandidate srflxCand)
+ {
+ DatagramSocket sock = srflxCand.getSocket();
+ stunStack.addSocket(sock);
+
+ try
+ {
+ stunStack.sendRequest( MessageFactory.createBindingRequest(),
+ stunServer, sock, this);
+
+ }
+ catch (Exception exception)
+ {
+ logger.log(Level.INFO, "Failed to send a refresh for a candidate",
+ exception);
+ }
+ }
}