org.lastbamboo.common.sip.client
Class SipClientImpl

java.lang.Object
  extended by org.lastbamboo.common.sip.client.SipClientImpl
All Implemented Interfaces:
EventListener, org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener, org.lastbamboo.common.offer.answer.Offerer, SipClient, org.littleshoot.mina.common.IoFutureListener, org.littleshoot.mina.common.IoServiceListener

public class SipClientImpl
extends Object
implements SipClient, org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener, org.littleshoot.mina.common.IoFutureListener, org.littleshoot.mina.common.IoServiceListener

Creates a new SIP client. This class supplies the interface for writing all SIP messages. It queues up messages on a separate thread from in-order writing.


Field Summary
 
Fields inherited from interface org.littleshoot.mina.common.IoFutureListener
CLOSE
 
Constructor Summary
SipClientImpl(URI sipClientUri, URI proxyUri, org.lastbamboo.common.sip.stack.message.SipMessageFactory messageFactory, org.lastbamboo.common.sip.stack.transaction.client.SipTransactionTracker transactionTracker, org.lastbamboo.common.offer.answer.OfferAnswerFactory offerAnswerFactory, InetSocketAddress serverAddress, org.littleshoot.util.SessionSocketListener callSocketListener, org.lastbamboo.common.sip.stack.util.UriUtils uriUtils, org.lastbamboo.common.sip.stack.transport.SipTcpTransportLayer transportLayer, SipClientCloseListener closeListener, CrlfDelayCalculator calculator, org.lastbamboo.common.sip.stack.IdleSipSessionListener idleSipSessionListener)
          Creates a new SIP client connection to an individual SIP proxy server.
 
Method Summary
 void connect()
          Connects to the proxy server.
 URI getContactUri()
          Accessor the contact URI for the client.
 org.apache.commons.id.uuid.UUID getInstanceId()
          Accessor for the unique instance ID for this client.
 URI getProxyUri()
          Accessor for the URI of the SIP proxy the client is connected to and registered with.
 URI getSipUri()
          Accessor for the SIP URI for this client.
 void offer(URI sipUri, byte[] body, org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener listener, org.littleshoot.util.KeyStorage keyStore)
           
 void onTransactionFailed(org.lastbamboo.common.offer.answer.OfferAnswerMessage message)
           
 void onTransactionSucceeded(org.lastbamboo.common.offer.answer.OfferAnswerMessage message)
           
 void operationComplete(org.littleshoot.mina.common.IoFuture future)
           
 void register()
          Registers the SIP client.
 void serviceActivated(org.littleshoot.mina.common.IoService service, SocketAddress serviceAddress, org.littleshoot.mina.common.IoHandler handler, org.littleshoot.mina.common.IoServiceConfig config)
           
 void serviceDeactivated(org.littleshoot.mina.common.IoService service, SocketAddress serviceAddress, org.littleshoot.mina.common.IoHandler handler, org.littleshoot.mina.common.IoServiceConfig config)
           
 void sessionCreated(org.littleshoot.mina.common.IoSession session)
           
 void sessionDestroyed(org.littleshoot.mina.common.IoSession session)
           
 void writeCrlfKeepAlive()
          Sends a CRLF keep-alive message, as specified in the SIP outbound draft at: http://www.ietf.org/internet-drafts/draft-ietf-sip-outbound-08.txt
 void writeInviteOk(org.lastbamboo.common.sip.stack.message.Invite invite, org.littleshoot.mina.common.ByteBuffer body)
          Sends an INVITE OK message.
 void writeInviteRejected(org.lastbamboo.common.sip.stack.message.Invite invite, int responseCode, String reasonPhrase)
          Writes an INVITE rejected response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipClientImpl

public SipClientImpl(URI sipClientUri,
                     URI proxyUri,
                     org.lastbamboo.common.sip.stack.message.SipMessageFactory messageFactory,
                     org.lastbamboo.common.sip.stack.transaction.client.SipTransactionTracker transactionTracker,
                     org.lastbamboo.common.offer.answer.OfferAnswerFactory offerAnswerFactory,
                     InetSocketAddress serverAddress,
                     org.littleshoot.util.SessionSocketListener callSocketListener,
                     org.lastbamboo.common.sip.stack.util.UriUtils uriUtils,
                     org.lastbamboo.common.sip.stack.transport.SipTcpTransportLayer transportLayer,
                     SipClientCloseListener closeListener,
                     CrlfDelayCalculator calculator,
                     org.lastbamboo.common.sip.stack.IdleSipSessionListener idleSipSessionListener)
Creates a new SIP client connection to an individual SIP proxy server.

Parameters:
sipClientUri - The URI of the client.
proxyUri - The URI of the proxy.
messageFactory - The factory for creating new SIP messages.
transactionTracker - The class for keeping track of SIP client transactions.
offerAnswerFactory - Factory for creating classes capable of handling offers and answers.
serverAddress - The listener for incoming sockets on the answerer.
uriUtils - Utilities for handling SIP URIs.
transportLayer - The class for actually sending SIP messages.
closeListener - The class that listens for closed connections to proxies.
calculator - The class that calculates the delay between double CRLF keep-alive messages, passed in for testing.
idleSipSessionListener - Listener for idle SIP sessions.
Method Detail

connect

public void connect()
             throws IOException
Description copied from interface: SipClient
Connects to the proxy server.

Specified by:
connect in interface SipClient
Throws:
IOException - If we cannot connect.

register

public void register()
              throws IOException
Description copied from interface: SipClient
Registers the SIP client.

Specified by:
register in interface SipClient
Throws:
IOException - If we do not get a successful registration response.

writeCrlfKeepAlive

public void writeCrlfKeepAlive()
Description copied from interface: SipClient
Sends a CRLF keep-alive message, as specified in the SIP outbound draft at: http://www.ietf.org/internet-drafts/draft-ietf-sip-outbound-08.txt

Specified by:
writeCrlfKeepAlive in interface SipClient

offer

public void offer(URI sipUri,
                  byte[] body,
                  org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener listener,
                  org.littleshoot.util.KeyStorage keyStore)
           throws IOException
Specified by:
offer in interface org.lastbamboo.common.offer.answer.Offerer
Throws:
IOException

getInstanceId

public org.apache.commons.id.uuid.UUID getInstanceId()
Description copied from interface: SipClient
Accessor for the unique instance ID for this client.

Specified by:
getInstanceId in interface SipClient
Returns:
The instance ID for this client.

getContactUri

public URI getContactUri()
Description copied from interface: SipClient
Accessor the contact URI for the client.

Specified by:
getContactUri in interface SipClient
Returns:
The contact URI for the client.

getSipUri

public URI getSipUri()
Description copied from interface: SipClient
Accessor for the SIP URI for this client.

Specified by:
getSipUri in interface SipClient
Returns:
The SIP URI for this client.

getProxyUri

public URI getProxyUri()
Description copied from interface: SipClient
Accessor for the URI of the SIP proxy the client is connected to and registered with.

Specified by:
getProxyUri in interface SipClient
Returns:
The URI of the SIP proxy the client is connected to and registered with.

onTransactionSucceeded

public void onTransactionSucceeded(org.lastbamboo.common.offer.answer.OfferAnswerMessage message)
Specified by:
onTransactionSucceeded in interface org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener

onTransactionFailed

public void onTransactionFailed(org.lastbamboo.common.offer.answer.OfferAnswerMessage message)
Specified by:
onTransactionFailed in interface org.lastbamboo.common.offer.answer.OfferAnswerTransactionListener

operationComplete

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

writeInviteOk

public void writeInviteOk(org.lastbamboo.common.sip.stack.message.Invite invite,
                          org.littleshoot.mina.common.ByteBuffer body)
Description copied from interface: SipClient
Sends an INVITE OK message.

Specified by:
writeInviteOk in interface SipClient
Parameters:
invite - The INVITE we're responding to.
body - The body of the INVITE OK.

writeInviteRejected

public void writeInviteRejected(org.lastbamboo.common.sip.stack.message.Invite invite,
                                int responseCode,
                                String reasonPhrase)
Description copied from interface: SipClient
Writes an INVITE rejected response.

Specified by:
writeInviteRejected in interface SipClient
Parameters:
invite - The invite.
responseCode - The response code.
reasonPhrase - The reason phrase for the error.

serviceActivated

public void serviceActivated(org.littleshoot.mina.common.IoService service,
                             SocketAddress serviceAddress,
                             org.littleshoot.mina.common.IoHandler handler,
                             org.littleshoot.mina.common.IoServiceConfig config)
Specified by:
serviceActivated in interface org.littleshoot.mina.common.IoServiceListener

serviceDeactivated

public void serviceDeactivated(org.littleshoot.mina.common.IoService service,
                               SocketAddress serviceAddress,
                               org.littleshoot.mina.common.IoHandler handler,
                               org.littleshoot.mina.common.IoServiceConfig config)
Specified by:
serviceDeactivated in interface org.littleshoot.mina.common.IoServiceListener

sessionCreated

public void sessionCreated(org.littleshoot.mina.common.IoSession session)
Specified by:
sessionCreated in interface org.littleshoot.mina.common.IoServiceListener

sessionDestroyed

public void sessionDestroyed(org.littleshoot.mina.common.IoSession session)
Specified by:
sessionDestroyed in interface org.littleshoot.mina.common.IoServiceListener


Copyright © 2013 LittleShoot. All Rights Reserved.