org.lastbamboo.common.sip.stack.message
Class SipMessageFactoryImpl

java.lang.Object
  extended by org.lastbamboo.common.sip.stack.message.SipMessageFactoryImpl
All Implemented Interfaces:
SipMessageFactory

public class SipMessageFactoryImpl
extends Object
implements SipMessageFactory

Factory for creating SIP messages. This can create messages from scratch or messages that arrive over the wire.


Constructor Summary
SipMessageFactoryImpl()
          Creates a new SIP message factory with the default header factory.
SipMessageFactoryImpl(SipHeaderFactory headerFactory)
          Creates a new SIP message factory.
 
Method Summary
 Invite addVia(Invite message, SipHeader newHeader)
          Copies all the data from the original message into a new message, adding the specified Via header.
 Register addVia(Register message, SipHeader newHeader)
          Copies all the data from the original message into a new message, adding the specified Via header.
 SipMessage createErrorResponse(SipMessage request, org.apache.commons.id.uuid.UUID instanceId, URI contactUri, int responseCode, String reasonPhrase)
          Creates an error response to the specified request.
 SipResponse createInviteOk(Invite request, org.apache.commons.id.uuid.UUID instanceId, URI contactUri, org.littleshoot.mina.common.ByteBuffer body)
          Creates a new INVITE OK message, copying data from the specified request.
 Invite createInviteRequest(String displayName, URI toUri, URI fromUri, org.apache.commons.id.uuid.UUID instanceId, URI contactUri, org.littleshoot.mina.common.ByteBuffer body)
          Creates a new invite request outside of a dialog.
 Invite createInviteToForward(InetSocketAddress socketAddress, Invite invite)
          Creates a new message to forward with all of the appropriate modifications to the Via header based on the remote reading of the socket address and port.
 SipResponse createRegisterOk(Register request)
          Creates a register OK message from the specified request.
 Register createRegisterRequest(URI requestUri, String displayName, URI toUri, org.apache.commons.id.uuid.UUID instanceId, URI contactUri)
          Creates a new register request.
 SipResponse createRequestTimeoutResponse(SipMessage request)
          Creates a 408 Request Timeout response.
 SipResponse stripVia(SipResponse response)
          Strips the topmost Via header from the response, returning a new message without the topmost Via.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipMessageFactoryImpl

public SipMessageFactoryImpl(SipHeaderFactory headerFactory)
Creates a new SIP message factory.

Parameters:
headerFactory - The collaborator class for creating SIP headers.

SipMessageFactoryImpl

public SipMessageFactoryImpl()
Creates a new SIP message factory with the default header factory.

Method Detail

createRegisterRequest

public Register createRegisterRequest(URI requestUri,
                                      String displayName,
                                      URI toUri,
                                      org.apache.commons.id.uuid.UUID instanceId,
                                      URI contactUri)
Description copied from interface: SipMessageFactory
Creates a new register request.

Specified by:
createRegisterRequest in interface SipMessageFactory
Parameters:
requestUri - The request URI for the request start line.
displayName - The display name to send the request to.
toUri - The URI to send the request to.
instanceId - The instance ID of the registering SIP entity.
contactUri - The contact URI of the registering SIP entity.
Returns:
The new SIP register request.

createInviteRequest

public Invite createInviteRequest(String displayName,
                                  URI toUri,
                                  URI fromUri,
                                  org.apache.commons.id.uuid.UUID instanceId,
                                  URI contactUri,
                                  org.littleshoot.mina.common.ByteBuffer body)
Description copied from interface: SipMessageFactory
Creates a new invite request outside of a dialog. This will generate a new Call-ID for the dialog.

Specified by:
createInviteRequest in interface SipMessageFactory
Parameters:
displayName - The name to display.
toUri - The SIP URI to send the message to.
fromUri - The SIP URI the message is from.
instanceId - The instance ID of the sending client, used in the contact header.
contactUri - The contact URI.
body - The body of the INVITE. This is typcically SDP.
Returns:
The new invite.

createInviteOk

public SipResponse createInviteOk(Invite request,
                                  org.apache.commons.id.uuid.UUID instanceId,
                                  URI contactUri,
                                  org.littleshoot.mina.common.ByteBuffer body)
Description copied from interface: SipMessageFactory
Creates a new INVITE OK message, copying data from the specified request.

Specified by:
createInviteOk in interface SipMessageFactory
Parameters:
request - The request to respond to with an OK response.
instanceId - The instance ID of the responding user.
contactUri - The contact URI of the responding user.
body - The body of the message.
Returns:
A new INVITE OK with the specified data.

createErrorResponse

public SipMessage createErrorResponse(SipMessage request,
                                      org.apache.commons.id.uuid.UUID instanceId,
                                      URI contactUri,
                                      int responseCode,
                                      String reasonPhrase)
Description copied from interface: SipMessageFactory
Creates an error response to the specified request.

Specified by:
createErrorResponse in interface SipMessageFactory
Parameters:
request - The request to create a response for.
instanceId - The instance ID of the resonding peer.
contactUri - The contact URI of the responding peer.
responseCode - The reason code for the response.
reasonPhrase - The reason phrase for the response.
Returns:
The new response message.

addVia

public Register addVia(Register message,
                       SipHeader newHeader)
Description copied from interface: SipMessageFactory
Copies all the data from the original message into a new message, adding the specified Via header.

Specified by:
addVia in interface SipMessageFactory
Parameters:
message - The original message to create a new message from.
newHeader - The Via header to add.
Returns:
A new SIP message with all the data from the original message plus the specified header.

addVia

public Invite addVia(Invite message,
                     SipHeader newHeader)
Description copied from interface: SipMessageFactory
Copies all the data from the original message into a new message, adding the specified Via header.

Specified by:
addVia in interface SipMessageFactory
Parameters:
message - The original message to create a new message from.
newHeader - The Via header to add.
Returns:
A new SIP message with all the data from the original message plus the specified header.

stripVia

public SipResponse stripVia(SipResponse response)
Description copied from interface: SipMessageFactory
Strips the topmost Via header from the response, returning a new message without the topmost Via.

Specified by:
stripVia in interface SipMessageFactory
Parameters:
response - The response message to strip the Via from.
Returns:
The new message without the topmost Via header from the original.

createRegisterOk

public SipResponse createRegisterOk(Register request)
Description copied from interface: SipMessageFactory
Creates a register OK message from the specified request.

Specified by:
createRegisterOk in interface SipMessageFactory
Parameters:
request - The register request to create an OK response for.
Returns:
The register OK response.

createRequestTimeoutResponse

public SipResponse createRequestTimeoutResponse(SipMessage request)
Description copied from interface: SipMessageFactory
Creates a 408 Request Timeout response.

Specified by:
createRequestTimeoutResponse in interface SipMessageFactory
Parameters:
request - The request that timed out.
Returns:
The 408 Request Timeout response.

createInviteToForward

public Invite createInviteToForward(InetSocketAddress socketAddress,
                                    Invite invite)
                             throws IOException
Description copied from interface: SipMessageFactory
Creates a new message to forward with all of the appropriate modifications to the Via header based on the remote reading of the socket address and port.

Specified by:
createInviteToForward in interface SipMessageFactory
Parameters:
socketAddress - The remote socket address the INVITE arrived from.
invite - The incoming INVITE message.
Returns:
A new INVITE message with appropriate modifications to the Via header.
Throws:
IOException - If the message does not match the expected syntax.


Copyright © 2013 LittleShoot. All Rights Reserved.