org.lastbamboo.common.sip.stack.transport
Class SipTcpTransportLayerImpl

java.lang.Object
  extended by org.lastbamboo.common.sip.stack.transport.SipTcpTransportLayerImpl
All Implemented Interfaces:
EventListener, SipTcpTransportLayer, org.littleshoot.mina.common.IoFutureListener

public final class SipTcpTransportLayerImpl
extends Object
implements SipTcpTransportLayer, org.littleshoot.mina.common.IoFutureListener

The transport layer implementation for TCP.


Field Summary
 
Fields inherited from interface org.littleshoot.mina.common.IoFutureListener
CLOSE
 
Constructor Summary
SipTcpTransportLayerImpl(SipTransactionFactory transactionFactory, SipHeaderFactory headerFactory, SipMessageFactory messageFactory)
          Constructs an instance of the TCP transport layer.
 
Method Summary
 void addConnection(org.littleshoot.mina.common.IoSession io)
          Adds a mapping between the remote host for the connection and the class for reading and writing data from and to that host.
 boolean hasConnectionForAny(Collection<InetSocketAddress> socketAddresses)
          Checks whether or not the transport layer has a connection to any of the specified socket addresses.
 SipClientTransaction invite(Invite request, org.littleshoot.mina.common.IoSession io, org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener transactionListener)
          Writes a message that is a part of a transaction.
 void operationComplete(org.littleshoot.mina.common.IoFuture future)
           
 SipClientTransaction register(Register request, org.littleshoot.mina.common.IoSession io, org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener transactionListener)
          Writes a REGISTER request that is a part of a transaction.
 void removeConnection(org.littleshoot.mina.common.IoSession io)
          Removes this connection.
 org.littleshoot.mina.common.WriteFuture writeCrlfKeepAlive(org.littleshoot.mina.common.IoSession io)
          Writes a CRLF keep-alive message to the given reader/writer, as specified in the SIP outbound drafts.
 void writeRequest(Collection<InetSocketAddress> socketAddresses, Invite request)
          Writes the specified request to the first address in the collection we have a connection for.
 void writeRequestStatelessly(Invite request, org.littleshoot.mina.common.IoSession io)
          Writes the specified request without creating a transaction.
 boolean writeResponse(InetSocketAddress socketAddress, SipResponse response)
          Writes the specified response message to the connection associated with the specified address.
 void writeResponse(SipResponse response)
          Writes a response using the routing information in the topmost Via header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipTcpTransportLayerImpl

public SipTcpTransportLayerImpl(SipTransactionFactory transactionFactory,
                                SipHeaderFactory headerFactory,
                                SipMessageFactory messageFactory)
Constructs an instance of the TCP transport layer.

Parameters:
transactionFactory - The factory for creating transactions.
headerFactory - The factory for creating any headers necessary before writing messages, such as the Via header.
messageFactory - The factory for creating SIP messages.
Method Detail

addConnection

public void addConnection(org.littleshoot.mina.common.IoSession io)
Description copied from interface: SipTcpTransportLayer
Adds a mapping between the remote host for the connection and the class for reading and writing data from and to that host.

Specified by:
addConnection in interface SipTcpTransportLayer
Parameters:
io - The connection to the host.

removeConnection

public void removeConnection(org.littleshoot.mina.common.IoSession io)
Description copied from interface: SipTcpTransportLayer
Removes this connection.

Specified by:
removeConnection in interface SipTcpTransportLayer
Parameters:
io - The connection to remove.

invite

public SipClientTransaction invite(Invite request,
                                   org.littleshoot.mina.common.IoSession io,
                                   org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener transactionListener)
Description copied from interface: SipTcpTransportLayer
Writes a message that is a part of a transaction. This method should add the transaction to a transaction map prior to sending it to ensure we don't receive responses prior to the maintaining data for the transaction.

Specified by:
invite in interface SipTcpTransportLayer
Parameters:
request - The SIP message we're sending.
io - The class for writing the message.
transactionListener - Class that listens for transaction events.
Returns:
The client transaction for the request.

register

public SipClientTransaction register(Register request,
                                     org.littleshoot.mina.common.IoSession io,
                                     org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener transactionListener)
Description copied from interface: SipTcpTransportLayer
Writes a REGISTER request that is a part of a transaction. This method should add the transaction to a transaction map prior to sending it to ensure we don't receive responses prior to the maintaining data for the transaction.

Specified by:
register in interface SipTcpTransportLayer
Parameters:
request - The SIP message we're sending.
io - The class for writing the message.
transactionListener - Class that listens for transaction events.
Returns:
The client transaction for the request.

writeRequestStatelessly

public void writeRequestStatelessly(Invite request,
                                    org.littleshoot.mina.common.IoSession io)
Description copied from interface: SipTcpTransportLayer
Writes the specified request without creating a transaction.

Specified by:
writeRequestStatelessly in interface SipTcpTransportLayer
Parameters:
request - The SIP request to write.
io - The class that will write hte message.

writeResponse

public boolean writeResponse(InetSocketAddress socketAddress,
                             SipResponse response)
Description copied from interface: SipTcpTransportLayer
Writes the specified response message to the connection associated with the specified address.

Specified by:
writeResponse in interface SipTcpTransportLayer
Parameters:
socketAddress - The address and port remote of the client to send the response to.
response - The response to send.
Returns:
Returns true of we successfull processed the response and passed it to the network for transport, otherwise false.

writeCrlfKeepAlive

public org.littleshoot.mina.common.WriteFuture writeCrlfKeepAlive(org.littleshoot.mina.common.IoSession io)
Description copied from interface: SipTcpTransportLayer
Writes a CRLF keep-alive message to the given reader/writer, as specified in the SIP outbound drafts. The keep-alive both keeps NATs from closing active connections and supplies insurance to detect when connections have been closed.

Specified by:
writeCrlfKeepAlive in interface SipTcpTransportLayer
Parameters:
io - The reader/writer to write the messages over.
Returns:
The future for the write.

writeResponse

public void writeResponse(SipResponse response)
                   throws IOException
Description copied from interface: SipTcpTransportLayer
Writes a response using the routing information in the topmost Via header.

Specified by:
writeResponse in interface SipTcpTransportLayer
Parameters:
response - The response to write.
Throws:
IOException - If we could not route the response for any reason.

hasConnectionForAny

public boolean hasConnectionForAny(Collection<InetSocketAddress> socketAddresses)
Description copied from interface: SipTcpTransportLayer
Checks whether or not the transport layer has a connection to any of the specified socket addresses.

Specified by:
hasConnectionForAny in interface SipTcpTransportLayer
Parameters:
socketAddresses - The collection of socket addresses to look for.
Returns:
true if there is a connection to any of the specified addresses, otherwise false.

writeRequest

public void writeRequest(Collection<InetSocketAddress> socketAddresses,
                         Invite request)
Description copied from interface: SipTcpTransportLayer
Writes the specified request to the first address in the collection we have a connection for.

Specified by:
writeRequest in interface SipTcpTransportLayer
Parameters:
socketAddresses - The socket addresses to attempt to send a message to.
request - The request to send.

operationComplete

public void operationComplete(org.littleshoot.mina.common.IoFuture future)
Specified by:
operationComplete in interface org.littleshoot.mina.common.IoFutureListener


Copyright © 2013 LittleShoot. All Rights Reserved.