This class defines a SIP Stack. In order to build a SIP server (UAS/UAC or
Proxy etc.) you need to extend this class and instantiate it in your
application. After you have done so, call
SIPMessageStack.createMessageProcessor to create message processors and then start these message processors to
get the stack the process messages.
This will start the necessary threads that wait for incoming SIP messages.
A general note about the handler structures -- handlers are expected to
returnResponse for successful message processing and throw
SIPServerException for unsuccessful message processing.
This code is in the public domain.
addMessageProcessor(MessageProcessor newMessageProcessor) Adds a new MessageProcessor to the list of running processors
for this SIPMessageStack and starts it.
isTransportEnabled(String transport) Returns true if a transport is enabled.
Parameters: transport - is the transport to check.
public boolean
isTransportEnabled(String transport, int port) Returns true if the transport is enabled for a given port.
Parameters: transport - transport to check Parameters: port - port to check transport at.
public void
logBadMessage(String message) Logs a bad message (invoked when a parse exception arises).
newSIPServerResponse(Response sipresponse, MessageChannel msgchan) Generates a new SIPSeverResponse from the given Response.
Parameters: sipresponse - Response from which the SIPServerResponseis to be generated.
setSingleThreaded() Sets the flag that instructs the stack to only start a single
thread for sequentially processing incoming udp messages (thus
serializing the processing).
Construcor for the stack. Registers the request and response
factories for the stack.
Parameters: messageFactory - User-implemented factory for processingmessages. Parameters: stackAddress - -- IP address or host name of the stack. Parameters: stackName - -- descriptive name for the stack.
Adds a new MessageProcessor to the list of running processors
for this SIPMessageStack and starts it. You can use this method
for dynamic stack configuration.
Acknowledgement: This code is contributed by Jeff Keyser.
Parameters: newMessageProcessor - the new message processor toregister
Creates a new MessageChannel for a given Hop.
Parameters: nextHop - Hop to create a MessageChannel to. A MessageChannel to the specified Hop, or null ifno MessageProcessors support contacting that Hop. throws: UnknwonHostException - If the host in the Hop doesn'texist.
Creates the equivalent of a JAIN listening point and attaches
to the stack.
Parameters: port - the message processor port address Parameters: transport - the message processor transport type the requested message processor
Gets an array of running MessageProcessors on this SIPMessageStack.
Acknowledgement: Jeff Keyser suggested that applications should
have access to the running message processors and contributed
this code.
an array of running message processors.
Gets port of the message processor (based on the transport). If
multiple ports are enabled for the same transport then the first
one is retrieved.
Parameters: transport - is the transport for which to get the port. the message processor port exception: IllegalArgumentException - if the transport is notsupported
Returns the status of the toExit flag.
true if the stack object is alive and false otherwise.
isTransportEnabled
public boolean isTransportEnabled(String transport)(Code)
Returns true if a transport is enabled.
Parameters: transport - is the transport to check. true if transport is enabled
isTransportEnabled
public boolean isTransportEnabled(String transport, int port)(Code)
Returns true if the transport is enabled for a given port.
Parameters: transport - transport to check Parameters: port - port to check transport at. true if transport is enabled
Generates a new SIPSeverRequest from the given Request. A
SIPServerRequest is generated by the application
SIPServerRequestFactoryImpl. The application registers the
factory implementation at the time the stack is initialized.
Parameters: siprequest - Request for which we want to generatethsi SIPServerRequest. Parameters: msgchan - Message channel for the request for whichwe want to generate the SIPServerRequest Generated SIPServerRequest.
Generates a new SIPSeverResponse from the given Response.
Parameters: sipresponse - Response from which the SIPServerResponseis to be generated. Note - this just calls the factory interfaceto do its work. The factory interface is provided by the user. Parameters: msgchan - Message channel for the SIPServerResponse SIPServerResponse generated from this SIPResponse
Sets the flag that instructs the stack to only start a single
thread for sequentially processing incoming udp messages (thus
serializing the processing).
Caution: If the user-defined function called by the
processing thread blocks, then the entire server will block.
Sets the thread pool size for processing incoming UDP messages.
Limit the total number of threads for processing udp messages.
Caution: If the user-defined function called by the
processing thread blocks, then the entire server will block.
Parameters: size - the new thread pool size
Makes the stack close all accept connections and return. This
is useful if you want to start/stop the stack several times from
your application. Caution : use of this function could cause
peculiar bugs as messages are prcessed asynchronously by the stack.