Add a CandidateTcpType field to candidate.
This commit is contained in:
parent
026bfff995
commit
c23438f8c2
@ -29,6 +29,26 @@ import org.ice4j.*;
|
||||
public abstract class Candidate<T extends Candidate<?>>
|
||||
implements Comparable<T>
|
||||
{
|
||||
/**
|
||||
* The maximum value for a candidate's type preference.
|
||||
*/
|
||||
public static final int MAX_TYPE_PREFERENCE = 126;
|
||||
|
||||
/**
|
||||
* The minimum value for a candidate's type preference.
|
||||
*/
|
||||
public static final int MIN_TYPE_PREFERENCE = 0;
|
||||
|
||||
/**
|
||||
* The maximum value for a candidate's local preference.
|
||||
*/
|
||||
public static final int MAX_LOCAL_PREFERENCE = 65535;
|
||||
|
||||
/**
|
||||
* The minimum value for a candidate's local preference.
|
||||
*/
|
||||
public static final int MIN_LOCAL_PREFERENCE = 0;
|
||||
|
||||
/**
|
||||
* The transport address represented by this candidate.
|
||||
*/
|
||||
@ -116,24 +136,9 @@ public abstract class Candidate<T extends Candidate<?>>
|
||||
private T relatedCandidate = null;
|
||||
|
||||
/**
|
||||
* The maximum value for a candidate's type preference.
|
||||
* The <tt>CandidateTcpType</tt> for this <tt>Candidate</tt>.
|
||||
*/
|
||||
public static final int MAX_TYPE_PREFERENCE = 126;
|
||||
|
||||
/**
|
||||
* The minimum value for a candidate's type preference.
|
||||
*/
|
||||
public static final int MIN_TYPE_PREFERENCE = 0;
|
||||
|
||||
/**
|
||||
* The maximum value for a candidate's local preference.
|
||||
*/
|
||||
public static final int MAX_LOCAL_PREFERENCE = 65535;
|
||||
|
||||
/**
|
||||
* The minimum value for a candidate's local preference.
|
||||
*/
|
||||
public static final int MIN_LOCAL_PREFERENCE = 0;
|
||||
private CandidateTcpType tcpType = null;
|
||||
|
||||
/**
|
||||
* Creates a candidate for the specified transport address and properties.
|
||||
@ -966,4 +971,22 @@ public abstract class Candidate<T extends Candidate<?>>
|
||||
{
|
||||
return CandidatePrioritizer.compareCandidates(this, candidate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>CandidateTcpType</tt> for this <tt>Candidate</tt>.
|
||||
* @return the <tt>CandidateTcpType</tt> for this <tt>Candidate</tt>.
|
||||
*/
|
||||
public CandidateTcpType getTcpType()
|
||||
{
|
||||
return tcpType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <tt>CandidateTcpType</tt> for this <tt>Candidate</tt>.
|
||||
* @param tcpType the <tt>CandidateTcpType</tt> to set.
|
||||
*/
|
||||
public void setTcpType(CandidateTcpType tcpType)
|
||||
{
|
||||
this.tcpType = tcpType;
|
||||
}
|
||||
}
|
||||
80
src/org/ice4j/ice/CandidateTcpType.java
Normal file
80
src/org/ice4j/ice/CandidateTcpType.java
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents the TCP types for ICE TCP candidates.
|
||||
* See http://tools.ietf.org/html/rfc6544
|
||||
*
|
||||
* @author Boris Grozev
|
||||
*/
|
||||
public enum CandidateTcpType
|
||||
{
|
||||
/**
|
||||
* The "active" TCP candidate type.
|
||||
*/
|
||||
ACTIVE("active"),
|
||||
|
||||
/**
|
||||
* The "passive" TCP candidate type.
|
||||
*/
|
||||
PASSIVE("passive"),
|
||||
|
||||
/**
|
||||
* The "so" (simultaneous-open) TCP candidate type.
|
||||
*/
|
||||
SO("so");
|
||||
|
||||
/**
|
||||
* The name of this <tt>CandidateTcpType</tt> instance.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Creates a <tt>CandidateTcpType</tt> instance with the specified name.
|
||||
*
|
||||
* @param name the name of the <tt>CandidateTcpType</tt> instance we'd
|
||||
* like to create.
|
||||
*/
|
||||
private CandidateTcpType(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this <tt>CandidateTcpType</tt> (e.g. "active",
|
||||
* "passive", or "so").
|
||||
*
|
||||
* @return the name of this <tt>CandidateTcpType</tt> (e.g. "active",
|
||||
* "passive", or "so").
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Parses the string <tt>candidateTcpTypeName</tt> and return the
|
||||
* corresponding <tt>CandidateTcpType</tt> instance.
|
||||
*
|
||||
* @throws IllegalArgumentException in case <tt>candidateTcpTypeName</tt> is
|
||||
* not a valid or currently supported candidate TCP type.
|
||||
*/
|
||||
public static CandidateTcpType parse(String candidateTcpTypeName)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
for (CandidateTcpType type : values())
|
||||
if (type.toString().equals(candidateTcpTypeName))
|
||||
return type;
|
||||
|
||||
throw new IllegalArgumentException(candidateTcpTypeName
|
||||
+ " is not a currently supported CandidateTcpType");
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,8 +89,8 @@ public enum CandidateType
|
||||
* Returns the name of this <tt>CandidateType</tt> (e.g. "host", "prflx",
|
||||
* "srflx", or "relay").
|
||||
*
|
||||
* @return the name of this <tt>Transport</tt> (e.g. "udp" or
|
||||
* "tcp").
|
||||
* @return the name of this <tt>CandidateType</tt> (e.g. "host", "prflx",
|
||||
* "srflx", or "relay").
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
|
||||
@ -8,6 +8,7 @@ package org.ice4j.ice;
|
||||
|
||||
import org.ice4j.*;
|
||||
import org.ice4j.socket.*;
|
||||
import org.ice4j.stack.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -55,11 +56,21 @@ public class TcpHostCandidate
|
||||
@Override
|
||||
protected void free()
|
||||
{
|
||||
super.free();
|
||||
StunStack stunStack = getStunStack();
|
||||
TransportAddress localAddr = getTransportAddress();
|
||||
for (IceSocketWrapper socket : sockets)
|
||||
{
|
||||
socket.close();
|
||||
//remove our sockets from the stack.
|
||||
stunStack.removeSocket(
|
||||
localAddr,
|
||||
new TransportAddress(
|
||||
socket.getTCPSocket().getInetAddress(),
|
||||
socket.getTCPSocket().getPort(),
|
||||
Transport.TCP));
|
||||
|
||||
socket.close();
|
||||
}
|
||||
|
||||
super.free();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user