Nothing really, mostly applies formatting.

This commit is contained in:
lubomir.marinov 2010-07-09 14:58:05 +00:00
parent 0e0e0086d1
commit cad31b0304
12 changed files with 66 additions and 75 deletions

View File

@ -7,14 +7,15 @@
package org.ice4j; package org.ice4j;
/** /**
* A StunException is thrown when a general STUN exception is encountered. * A <tt>StunException</tt> is thrown when a general STUN exception is
* encountered.
* *
* @author Emil Ivov * @author Emil Ivov
*/ */
public class StunException extends Exception public class StunException extends Exception
{ {
/** /**
* Serial version UID for this Serializable class. * Serial version UID for this <tt>Serializable</tt> class.
*/ */
private static final long serialVersionUID = 35367793L; private static final long serialVersionUID = 35367793L;

View File

@ -265,7 +265,7 @@ public class TransportAddress
} }
} }
//may add more unreachability condition here in the future; //may add more unreachability conditions here in the future;
return true; return true;
} }

View File

@ -101,18 +101,13 @@ public class DataAttribute
} }
/** /**
* Returns a (cloned) byte array containg the data value of the data * Returns a (cloned) byte array containing the data value of the data
* attribute. * attribute.
* @return the binary array containing the data. * @return the binary array containing the data.
*/ */
public byte[] getData() public byte[] getData()
{ {
if (data == null) return (data == null) ? null : data.clone();
return null;
byte[] copy = new byte[data.length];
System.arraycopy(data, 0, copy, 0, data.length);
return data;
} }
/** /**

View File

@ -1341,7 +1341,7 @@ public class Agent
{ {
if (terminationThread == null) if (terminationThread == null)
{ {
terminationThread = new TerminationThread(this); terminationThread = new TerminationThread();
terminationThread.start(); terminationThread.start();
} }
} }
@ -1356,23 +1356,16 @@ public class Agent
* This <tt>TerminationThread</tt> is scheduling such a termination and * This <tt>TerminationThread</tt> is scheduling such a termination and
* garbage collection in three seconds. * garbage collection in three seconds.
*/ */
private static class TerminationThread private class TerminationThread
extends Thread extends Thread
{ {
/**
* The parent agent that created us.
*/
private final Agent parentAgent;
/** /**
* Creates a new termination timer. * Creates a new termination timer.
*
* @param parentAgent the <tt>Agent</tt> that created us.
*/ */
private TerminationThread(Agent parentAgent) private TerminationThread()
{ {
super("TerminationThread"); super("TerminationThread");
this.parentAgent = parentAgent;
} }
/** /**
@ -1380,6 +1373,7 @@ public class Agent
* interval the user has specified) and then moves this <tt>Agent</tt> * interval the user has specified) and then moves this <tt>Agent</tt>
* into the terminated state and frees all non-nominated candidates. * into the terminated state and frees all non-nominated candidates.
*/ */
@Override
public synchronized void run() public synchronized void run()
{ {
long terminationDelay = Integer.getInteger( long terminationDelay = Integer.getInteger(
@ -1401,7 +1395,7 @@ public class Agent
} }
} }
parentAgent.terminate(IceProcessingState.TERMINATED); terminate(IceProcessingState.TERMINATED);
} }
} }
@ -1417,9 +1411,7 @@ public class Agent
{ {
// free candidates // free candidates
for(IceMediaStream stream : getStreams()) for(IceMediaStream stream : getStreams())
{
removeStream(stream); removeStream(stream);
}
// stop listening for checks // stop listening for checks
connCheckClient.stop(); connCheckClient.stop();

View File

@ -106,17 +106,17 @@ class ConnectivityCheckClient
*/ */
private TransactionID startCheckForPair(CandidatePair candidatePair) private TransactionID startCheckForPair(CandidatePair candidatePair)
{ {
LocalCandidate localCandidate = candidatePair.getLocalCandidate();
//we don't need to do a canReach() verification here as it has been //we don't need to do a canReach() verification here as it has been
//already verified during the gathering process. //already verified during the gathering process.
DatagramSocket stunSocket DatagramSocket stunSocket = localCandidate.getStunSocket(null);
= candidatePair.getLocalCandidate().getStunSocket(null);
Request request = MessageFactory.createBindingRequest(); Request request = MessageFactory.createBindingRequest();
//the priority we'd like the remote party to use for a peer reflexive //the priority we'd like the remote party to use for a peer reflexive
//candidate if one is discovered as a consequence of this check. //candidate if one is discovered as a consequence of this check.
PriorityAttribute priority = AttributeFactory.createPriorityAttribute( PriorityAttribute priority = AttributeFactory.createPriorityAttribute(
candidatePair.getLocalCandidate().computePriorityForType( localCandidate.computePriorityForType(
CandidateType.PEER_REFLEXIVE_CANDIDATE)); CandidateType.PEER_REFLEXIVE_CANDIDATE));
request.addAttribute(priority); request.addAttribute(priority);
@ -148,7 +148,7 @@ class ConnectivityCheckClient
request.addAttribute(unameAttr); request.addAttribute(unameAttr);
//todo: also implement SASL prepare // TODO Also implement SASL prepare
MessageIntegrityAttribute msgIntegrity = AttributeFactory MessageIntegrityAttribute msgIntegrity = AttributeFactory
.createMessageIntegrityAttribute(localUserName); .createMessageIntegrityAttribute(localUserName);
@ -159,26 +159,30 @@ class ConnectivityCheckClient
try try
{ {
stunStack.sendRequest(request, tran
candidatePair.getRemoteCandidate().getTransportAddress(), = stunStack.sendRequest(request,
candidatePair.getLocalCandidate().getTransportAddress(), candidatePair
this, tran); .getRemoteCandidate().getTransportAddress(),
localCandidate.getTransportAddress(),
this,
tran);
if(logger.isLoggable(Level.FINEST)) if(logger.isLoggable(Level.FINEST))
logger.finest("checking pair " + candidatePair + " with tran=" {
+ tran); logger.finest(
"checking pair " + candidatePair
return tran; + " with tran=" + tran);
}
} }
catch (Exception exception) catch (Exception ex)
{ {
logger.log( Level.INFO, logger.log(
"Failed to send " + request + " through " Level.INFO,
+ stunSocket.getLocalSocketAddress(), "Failed to send " + request
exception); + " through " + stunSocket.getLocalSocketAddress(),
ex);
return null; tran = null;
} }
return tran;
} }
/** /**
@ -193,7 +197,7 @@ class ConnectivityCheckClient
public void processResponse(StunResponseEvent evt) public void processResponse(StunResponseEvent evt)
{ {
CandidatePair checkedPair CandidatePair checkedPair
= ((CandidatePair)evt.getTransactionID().getApplicationData()); = (CandidatePair) evt.getTransactionID().getApplicationData();
//make sure that the response came from the right place. //make sure that the response came from the right place.
if (!checkSymmetricAddresses(evt)) if (!checkSymmetricAddresses(evt))
@ -296,8 +300,8 @@ class ConnectivityCheckClient
Response response = evt.getResponse(); Response response = evt.getResponse();
Request request = evt.getRequest(); Request request = evt.getRequest();
CandidatePair checkedPair = ((CandidatePair)evt.getTransactionID() CandidatePair checkedPair
.getApplicationData()); = (CandidatePair) evt.getTransactionID().getApplicationData();
if(! response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS)) if(! response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS))
{ {

View File

@ -14,32 +14,33 @@ package org.ice4j.message;
* *
* @author Sebastien Vincent * @author Sebastien Vincent
*/ */
public class Indication extends Message public class Indication
extends Message
{ {
/** /**
* Constructor. * Constructor.
*/ */
Indication() Indication()
{ {
} }
/** /**
* Checks whether indicationType is a valid response type and if yes sets it * Checks whether indicationType is a valid indication type and if yes sets
* as the type of the current instance. * it as the type of this instance.
*
* @param indicationType the type to set * @param indicationType the type to set
* @throws IllegalArgumentException if indicationType is not a valid * @throws IllegalArgumentException if indicationType is not a valid
* response type * indication type
*/ */
@Override
public void setMessageType(char indicationType) public void setMessageType(char indicationType)
throws IllegalArgumentException throws IllegalArgumentException
{ {
if(!isIndicationType(indicationType)) if(!isIndicationType(indicationType))
throw new IllegalArgumentException( throw new IllegalArgumentException(
(int)(indicationType) (int)(indicationType)
+ " - is not a valid response type."); + " - is not a valid indication type.");
super.setMessageType(indicationType); super.setMessageType(indicationType);
} }
} }

View File

@ -15,7 +15,7 @@ import org.ice4j.*;
* *
* @author Emil Ivov * @author Emil Ivov
*/ */
interface MessageEventHandler public interface MessageEventHandler
{ {
/** /**
* Called when an incoming message has been received, parsed and is ready * Called when an incoming message has been received, parsed and is ready

View File

@ -44,7 +44,7 @@ class MessageProcessor
/** /**
* The flag that indicates whether we are still running. * The flag that indicates whether we are still running.
*/ */
private boolean isRunning = false; private boolean running = false;
/** /**
* A reference to the thread that we use to execute ourselves. * A reference to the thread that we use to execute ourselves.
@ -93,7 +93,7 @@ class MessageProcessor
//avoid having dead threads in our pools. //avoid having dead threads in our pools.
try try
{ {
while (isRunning) while (running)
{ {
RawMessage rawMessage; RawMessage rawMessage;
try try
@ -127,7 +127,7 @@ class MessageProcessor
} }
catch (StunException ex) catch (StunException ex)
{ {
errorHandler.handleError("Failed to decode a stun mesage!", errorHandler.handleError("Failed to decode a stun message!",
ex); ex);
continue; //let this one go and for better luck next time. continue; //let this one go and for better luck next time.
@ -153,20 +153,19 @@ class MessageProcessor
*/ */
void start() void start()
{ {
this.isRunning = true; this.running = true;
runningThread = new Thread(this, "Stun4J Message Processor"); runningThread = new Thread(this, "Stun4J Message Processor");
runningThread.setDaemon(true); runningThread.setDaemon(true);
runningThread.start(); runningThread.start();
} }
/** /**
* Shut down the message processor. * Shut down the message processor.
*/ */
void stop() void stop()
{ {
this.isRunning = false; this.running = false;
runningThread.interrupt(); runningThread.interrupt();
} }
@ -178,6 +177,6 @@ class MessageProcessor
*/ */
boolean isRunning() boolean isRunning()
{ {
return isRunning; return running;
} }
} }

View File

@ -143,18 +143,20 @@ class NetAccessManager
*/ */
protected void addSocket(DatagramSocket socket) protected void addSocket(DatagramSocket socket)
{ {
//no null check - let it through a null pointer exception //no null check - let it through as a NullPointerException
TransportAddress localAddr = new TransportAddress( TransportAddress localAddr
socket.getLocalAddress(), socket.getLocalPort(), Transport.UDP); = new TransportAddress(
socket.getLocalAddress(),
socket.getLocalPort(),
Transport.UDP);
if(netAccessPoints.containsKey(localAddr)) if (!netAccessPoints.containsKey(localAddr))
return; {
Connector ap = new Connector(socket, messageQueue, this);
Connector ap = new Connector(socket, messageQueue, this); netAccessPoints.put(localAddr, ap);
ap.start();
netAccessPoints.put(localAddr, ap); }
ap.start();
} }
/** /**

View File

@ -324,7 +324,6 @@ class StunClientTransaction
} }
} }
/** /**
* Cancels the transaction. Once this method is called the transaction is * Cancels the transaction. Once this method is called the transaction is
* considered terminated and will stop retransmissions. * considered terminated and will stop retransmissions.

View File

@ -32,7 +32,6 @@ import org.ice4j.message.*;
* *
* @author Emil Ivov * @author Emil Ivov
*/ */
class StunServerTransaction class StunServerTransaction
implements Runnable implements Runnable
{ {

View File

@ -18,11 +18,10 @@ import org.ice4j.stack.*;
/** /**
* The class provides basic means of discovering a public IP address. All it * The class provides basic means of discovering a public IP address. All it
* does is send a binding request through a specified port and return the * does is send a binding request through a specified port and return the
* mapped address it got back or <tt>null</tt> if there was no reponse. * mapped address it got back or <tt>null</tt> if there was no response.
* *
* @author Emil Ivov * @author Emil Ivov
*/ */
public class SimpleAddressDetector public class SimpleAddressDetector
{ {
/** /**