Adds getSocket() to Candidate instead of having it just in HostCandidate.

This commit is contained in:
lubomir.marinov 2010-02-26 12:08:46 +00:00
parent 67ead68836
commit 4e165d5f4e
3 changed files with 42 additions and 10 deletions

View File

@ -24,8 +24,9 @@ import org.ice4j.*;
* </p>
*
* @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 <tt>DatagramSocket</tt> associated with this <tt>Candidate</tt>.
*
* @return the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>
*/
public abstract DatagramSocket getSocket();
/**
* Returns the type of this candidate which should be an instance of the
* {@link CandidateType} enumeration.

View File

@ -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 <tt>DatagramSocket</tt> associated with this candidate.
* Gets the <tt>DatagramSocket</tt> associated with this <tt>Candidate</tt>.
*
* @return the <tt>DatagramSocket</tt> associated with this candidate.
* @return the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>
* @see Candidate#getSocket()
*/
public DatagramSocket getSocket()
{

View File

@ -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.*;
/**
* <tt>ServerReflexiveCandidate</tt>s 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. <tt>ServerReflexiveCandidate</tt>s 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. <tt>ServerReflexiveCandidate</tt>s can be learned by
* STUN servers using the Binding Request, or TURN servers, which provides both
* a Relayed and Server Reflexive candidate.
* <p>
* 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.
* </p>
*
* @author Emil Ivov
@ -40,4 +49,16 @@ public class ServerReflexiveCandidate extends Candidate
setBase(base);
setStunServerAddress(stunSrvrAddr);
}
/**
* Gets the <tt>DatagramSocket</tt> associated with this <tt>Candidate</tt>.
*
* @return the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>
* @see Candidate#getSocket()
*/
public DatagramSocket getSocket()
{
return getBase().getSocket();
}
}