org.littleshoot.stun.stack.transaction
Class StunClientTransactionImpl

java.lang.Object
  extended by org.littleshoot.stun.stack.transaction.StunClientTransactionImpl
All Implemented Interfaces:
StunMessageVisitor<StunMessage>, StunClientTransaction<StunMessage>

public class StunClientTransactionImpl
extends Object
implements StunClientTransaction<StunMessage>

Implementation of a STUN client transaction.


Constructor Summary
StunClientTransactionImpl(StunMessage request, List<StunTransactionListener> transactionListeners, InetSocketAddress remoteAddress)
          Creates a new STUN client transaction.
StunClientTransactionImpl(StunMessage request, StunTransactionListener transactionListener, InetSocketAddress remoteAddress)
          Creates a new STUN client transaction.
 
Method Summary
 void addListener(StunTransactionListener listener)
          Adds a listener to the transaction.
 InetSocketAddress getIntendedDestination()
          Gets the destination host the transaction was intended for.
 StunMessage getRequest()
          Accessor for the request that started the transaction.
 long getTransactionTime()
          Accessor for the total transaction time for the transaction.
 StunMessage visitAllocateErrorResponse(AllocateErrorResponse response)
          Visits a response for a failed Allocate Request.
 StunMessage visitAllocateRequest(AllocateRequest request)
          Visits the TURN usage allocate request message.
 StunMessage visitAllocateSuccessResponse(AllocateSuccessResponse response)
          Visits a response for a successful Allocate Request.
 StunMessage visitBindingErrorResponse(BindingErrorResponse response)
          Visits a binding error response.
 StunMessage visitBindingRequest(BindingRequest binding)
          Visits a binding message.
 StunMessage visitBindingSuccessResponse(BindingSuccessResponse response)
          Visits a binding success response.
 StunMessage visitCanceledMessage(CanceledStunMessage message)
          Visits a STUN message indicating the STUN transaction was canceled.
 StunMessage visitConnectErrorMesssage(ConnectErrorStunMessage message)
          Visits a STUN "message" indicating there was a connection error, such as an ICMP error or a failure to create a TCP connection.
 StunMessage visitConnectionStatusIndication(ConnectionStatusIndication indication)
          Visits a connection status indication message informing clients of the connection status of remote hosts.
 StunMessage visitConnectRequest(ConnectRequest request)
          Visits a connection request from a client.
 StunMessage visitDataIndication(DataIndication data)
           
 StunMessage visitNullMessage(NullStunMessage message)
          Visits the absence of a message.
 StunMessage visitSendIndication(SendIndication request)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StunClientTransactionImpl

public StunClientTransactionImpl(StunMessage request,
                                 List<StunTransactionListener> transactionListeners,
                                 InetSocketAddress remoteAddress)
Creates a new STUN client transaction.

Parameters:
request - The request starting the transaction.
transactionListeners - The listeners for transaction events.
remoteAddress - The remote address for the transaction.

StunClientTransactionImpl

public StunClientTransactionImpl(StunMessage request,
                                 StunTransactionListener transactionListener,
                                 InetSocketAddress remoteAddress)
Creates a new STUN client transaction.

Parameters:
request - The request starting the transaction.
transactionListener - The listener for transaction events.
remoteAddress - The remote address for the transaction.
Method Detail

addListener

public void addListener(StunTransactionListener listener)
Description copied from interface: StunClientTransaction
Adds a listener to the transaction. This should typically be called before any message has been sent -- before the transaction has started -- to ensure events aren't missed.

Specified by:
addListener in interface StunClientTransaction<StunMessage>
Parameters:
listener - The listener to add.

getRequest

public StunMessage getRequest()
Description copied from interface: StunClientTransaction
Accessor for the request that started the transaction.

Specified by:
getRequest in interface StunClientTransaction<StunMessage>
Returns:
The request that started the transaction.

getTransactionTime

public long getTransactionTime()
Description copied from interface: StunClientTransaction
Accessor for the total transaction time for the transaction.

Specified by:
getTransactionTime in interface StunClientTransaction<StunMessage>
Returns:
The total time the transaction took.

getIntendedDestination

public InetSocketAddress getIntendedDestination()
Description copied from interface: StunClientTransaction
Gets the destination host the transaction was intended for. This allows handlers to verify that the source of incoming packets is the source we expect.

Specified by:
getIntendedDestination in interface StunClientTransaction<StunMessage>
Returns:
The intended destination host.

visitBindingSuccessResponse

public StunMessage visitBindingSuccessResponse(BindingSuccessResponse response)
Description copied from interface: StunMessageVisitor
Visits a binding success response.

Specified by:
visitBindingSuccessResponse in interface StunMessageVisitor<StunMessage>
Parameters:
response - The binding success response.
Returns:
The return type for this visitor.

visitBindingErrorResponse

public StunMessage visitBindingErrorResponse(BindingErrorResponse response)
Description copied from interface: StunMessageVisitor
Visits a binding error response.

Specified by:
visitBindingErrorResponse in interface StunMessageVisitor<StunMessage>
Parameters:
response - Binding error response.
Returns:
The return type for this visitor.

visitConnectErrorMesssage

public StunMessage visitConnectErrorMesssage(ConnectErrorStunMessage message)
Description copied from interface: StunMessageVisitor
Visits a STUN "message" indicating there was a connection error, such as an ICMP error or a failure to create a TCP connection.

Specified by:
visitConnectErrorMesssage in interface StunMessageVisitor<StunMessage>
Parameters:
message - The connection error message.
Returns:
The type the visitor returns.

visitBindingRequest

public StunMessage visitBindingRequest(BindingRequest binding)
Description copied from interface: StunMessageVisitor
Visits a binding message.

Specified by:
visitBindingRequest in interface StunMessageVisitor<StunMessage>
Parameters:
binding - The binding message.
Returns:
The return type for this visitor.

visitAllocateRequest

public StunMessage visitAllocateRequest(AllocateRequest request)
Description copied from interface: StunMessageVisitor
Visits the TURN usage allocate request message.

Specified by:
visitAllocateRequest in interface StunMessageVisitor<StunMessage>
Parameters:
request - The TURN usage allocate request.
Returns:
The return type for this visitor.

visitDataIndication

public StunMessage visitDataIndication(DataIndication data)
Specified by:
visitDataIndication in interface StunMessageVisitor<StunMessage>

visitSendIndication

public StunMessage visitSendIndication(SendIndication request)
Specified by:
visitSendIndication in interface StunMessageVisitor<StunMessage>

visitAllocateSuccessResponse

public StunMessage visitAllocateSuccessResponse(AllocateSuccessResponse response)
Description copied from interface: StunMessageVisitor
Visits a response for a successful Allocate Request.

Specified by:
visitAllocateSuccessResponse in interface StunMessageVisitor<StunMessage>
Parameters:
response - The response to a successful Allocate Request.
Returns:
The return type for this visitor.

visitAllocateErrorResponse

public StunMessage visitAllocateErrorResponse(AllocateErrorResponse response)
Description copied from interface: StunMessageVisitor
Visits a response for a failed Allocate Request.

Specified by:
visitAllocateErrorResponse in interface StunMessageVisitor<StunMessage>
Parameters:
response - The response to a failed Allocate Request.
Returns:
The return type for this visitor.

visitConnectRequest

public StunMessage visitConnectRequest(ConnectRequest request)
Description copied from interface: StunMessageVisitor
Visits a connection request from a client. Only STUN servers will respond to this request. This request indicates the client wishes to allow connections from the host specified in the REMOTE ADDRESS attribute.

Specified by:
visitConnectRequest in interface StunMessageVisitor<StunMessage>
Parameters:
request - The connect request.
Returns:
The return type for this visitor.

visitConnectionStatusIndication

public StunMessage visitConnectionStatusIndication(ConnectionStatusIndication indication)
Description copied from interface: StunMessageVisitor
Visits a connection status indication message informing clients of the connection status of remote hosts. The connection status is sent in the CONNECT STAT attribute.

Specified by:
visitConnectionStatusIndication in interface StunMessageVisitor<StunMessage>
Parameters:
indication - The connection status indication message.
Returns:
The return type for this visitor.

visitNullMessage

public StunMessage visitNullMessage(NullStunMessage message)
Description copied from interface: StunMessageVisitor
Visits the absence of a message. This can occur, for example, when a request receives no response whatsoever.

Specified by:
visitNullMessage in interface StunMessageVisitor<StunMessage>
Parameters:
message - The message to visit.
Returns:
The return type for this visitor.

visitCanceledMessage

public StunMessage visitCanceledMessage(CanceledStunMessage message)
Description copied from interface: StunMessageVisitor
Visits a STUN message indicating the STUN transaction was canceled. This allows visitors to differentiate between canceled messages and messages where the server never responded.

Specified by:
visitCanceledMessage in interface StunMessageVisitor<StunMessage>
Parameters:
message - The canceled message.
Returns:
The type the visitor returns.


Copyright © 2013 LittleShoot. All Rights Reserved.