}
public void init(String threads, String timeout, int sleep, String transport) {
SipFactory sipFactory = null;
this.sleep = sleep;
sipStack = null;
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
// If you want to try TCP transport change the following to
String peerHostPort = "127.0.0.1:5070";
// properties.setProperty("javax.sip.OUTBOUND_PROXY", peerHostPort + "/"
// + transport);
// If you want to use UDP then uncomment this.
properties.setProperty("javax.sip.STACK_NAME", "shootist");
// The following properties are specific to nist-sip
// and are not necessarily part of any other jain-sip
// implementation.
// You can set a max message size for tcp transport to
// guard against denial of service attack.
properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
"shootistdebug.txt");
properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
"shootistlog.txt");
// Drop the client connection after we are done with the transaction.
properties.setProperty("gov.nist.javax.sip.CACHE_CLIENT_CONNECTIONS",
"false");
// Set to 0 (or NONE) in your production code for max speed.
// You need 16 (or TRACE) for logging traces. 32 (or DEBUG) for debug + traces.
// Your code will limp at 32 but it is best for debugging.
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "LOG4J");
Logger root = Logger.getRootLogger();
root.setLevel(Level.WARN);
root.addAppender(new ConsoleAppender(
new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
if(threads!=null) {
properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER", "true");
properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", threads);
properties.setProperty("gov.nist.javax.sip.TCP_POST_PARSING_THREAD_POOL_SIZE", threads);
}
properties.setProperty("gov.nist.javax.sip.CONGESTION_CONTROL_TIMEOUT", timeout);
properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");
properties.setProperty("gov.nist.javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING","false");
if(System.getProperty("enableNIO") != null && System.getProperty("enableNIO").equalsIgnoreCase("true")) {
properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", NioMessageProcessorFactory.class.getName());
}
try {
// Create SipStack object
sipStack = sipFactory.createSipStack(properties);
System.out.println("createSipStack " + sipStack);
} catch (PeerUnavailableException e) {
// could not find
// gov.nist.jain.protocol.ip.sip.SipStackImpl
// in the classpath
e.printStackTrace();
System.err.println(e.getMessage());
fail("Problem with setup");
}
try {
headerFactory = sipFactory.createHeaderFactory();
addressFactory = sipFactory.createAddressFactory();
messageFactory = sipFactory.createMessageFactory();
udpListeningPoint = sipStack.createListeningPoint("127.0.0.1", 5060, transport);
sipProvider = sipStack.createSipProvider(udpListeningPoint);
Shootist listener = this;
sipProvider.addSipListener(listener);