Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package performance.uas;
  
  import java.util.Calendar;
  import java.util.Date;
  
This is the UAS application for performance testing

Author(s):
Vladimir Ralev
 
 public class ShootmeDialogStateless implements SipListener {
 
     private static AddressFactory addressFactory;
 
     private static MessageFactory messageFactory;
 
     private static HeaderFactory headerFactory;
 
     private static SipStack sipStack;
 
     private static final String myAddress = "127.0.0.1";
 
     private static final int myPort = 5080;
 
 
     protected static final String usageString = "java "
             + ShootmeDialogStateless.class.getCanonicalName() + " \n"
             + ">>>> is your class path set to the root?";
 
     private static void usage() {
         ..println();
         System.exit(0);
 
     }
 
     public void processRequest(RequestEvent requestEvent) {
         final Request request = requestEvent.getRequest();
 	final ServerTransaction serverTransactionId = requestEvent.getServerTransaction();
 
         if (request.getMethod().equals(.)) {
             processInvite(requestEventserverTransactionId);
         } else if (request.getMethod().equals(.)) {
             processAck(requestEventserverTransactionId);
         } else if (request.getMethod().equals(.)) {
             processBye(requestEventserverTransactionId);
         } else if (request.getMethod().equals(.)) {
             processCancel(requestEventserverTransactionId);
         }
 
     }
 
     public void processResponse(ResponseEvent responseEvent) {
     }

    
Process the ACK request.
 
     public void processAck(RequestEvent requestEvent,
             ServerTransaction serverTransaction) {
 
     }

    
Process the invite request.
 
     public void processInvite(RequestEvent requestEvent,
             ServerTransaction serverTransaction) {
 
         final Request request = requestEvent.getRequest();
         final SipProvider sipProvider = (SipProviderrequestEvent.getSource();
         ServerTransaction st = serverTransaction;        
         try {        	
         	if (st == null) {
         		try {
        			st = sipProvider.getNewServerTransaction(request);
catch ( TransactionUnavailableException tae) {
	                return;
catch ( TransactionAlreadyExistsException taex ) {
					// This is a retransmission so just return.
					return;				
				}         		
            }
        	final String toTag = ""+System.nanoTime();
            Response response = .createResponse(.,
                    request);            
            ToHeader toHeader = (ToHeaderresponse.getHeader(.);
            toHeader.setTag(toTag); // Application is supposed to set.
            st.sendResponse(response);
            response = .createResponse(.,
                    request);
            final Address address = .createAddress("Shootme <sip:"
                    +  + ":" +  + ">");
            final ContactHeader contactHeader = 
                    .createContactHeader(address);
            response.addHeader(contactHeader);
            toHeader = (ToHeaderresponse.getHeader(.);
            toHeader.setTag(toTag); // Application is supposed to set.
            st.sendResponse(response);
        } catch (Exception ex) {
            ex.printStackTrace();
            //System.exit(0);
        }
    }


    
Process the bye request.
    public void processBye(RequestEvent requestEvent,
            ServerTransaction serverTransactionId) {
        final Request request = requestEvent.getRequest();
        
        try {
        	if (serverTransactionId == null) {
        		try {
        			serverTransactionId = ((SipProvider)requestEvent.getSource()).getNewServerTransaction(request);
catch ( TransactionUnavailableException tae) {
	                return;
catch ( TransactionAlreadyExistsException taex ) {
					// This is a retransmission so just return.
					return;				
				}              	
            }
            final Response response = .createResponse(200, request);            
            serverTransactionId.sendResponse(response);
        } catch (Exception ex) {
            ex.printStackTrace();
            //System.exit(0);
        }
    }
    public void processCancel(RequestEvent requestEvent,
            ServerTransaction serverTransactionId) {
    }
    public void processTimeout(javax.sip.TimeoutEvent timeoutEvent) {
    }
    public void init() {
        SipFactory sipFactory = null;
         = null;
        sipFactory = SipFactory.getInstance();
        sipFactory.setPathName("gov.nist");
        Properties properties = new Properties();
        properties.setProperty("javax.sip.STACK_NAME""shootme");
        // You need 16 for logging traces. 32 for debug + traces.
        // Your code will limp at 32 but it is best for debugging.
        properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL""0");
        properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT""false");
        properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT""off");        
        properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
                "shootmedebug.txt");
        properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
        "shootmelog.txt");
        properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
        "shootmedebug.txt");
        properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
        "shootmelog.txt");
        properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER",
        "true");
        properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE""4");
        properties.setProperty("gov.nist.javax.sip.RECEIVE_UDP_BUFFER_SIZE""65536");
        properties.setProperty("gov.nist.javax.sip.SEND_UDP_BUFFER_SIZE""65536");
        properties.setProperty("gov.nist.javax.sip.CONGESTION_CONTROL_ENABLED""false");        
        try {
            // Create SipStack object
             = sipFactory.createSipStack(properties);
        } catch (PeerUnavailableException e) {
            // could not find
            // gov.nist.jain.protocol.ip.sip.SipStackImpl
            // in the classpath
            e.printStackTrace();
            ..println(e.getMessage());
            if (e.getCause() != null)
                e.getCause().printStackTrace();
            System.exit(0);
        }
        try {
             = sipFactory.createHeaderFactory();
             = sipFactory.createAddressFactory();
             = sipFactory.createMessageFactory();
            ListeningPoint lp = .createListeningPoint("127.0.0.1",
                    "udp");
            ShootmeDialogStateless listener = this;
            SipProvider sipProvider = .createSipProvider(lp);
            sipProvider.addSipListener(listener);
        } catch (Exception ex) {
            ex.printStackTrace();
            usage();
        }
    }
    public static void main(String args[]) {
        new ShootmeDialogStateless().init();
    }
    public void processIOException(IOExceptionEvent exceptionEvent) {
    }
    public void processTransactionTerminated(
            TransactionTerminatedEvent transactionTerminatedEvent) {
//    	System.out.println("Tx Term Event : " + new SimpleDateFormat("hh:mm:ss").format(new Date(Calendar.getInstance().getTimeInMillis())) + " \n" + transactionTerminatedEvent.getServerTransaction().getRequest());
    }
    public void processDialogTerminated(
            DialogTerminatedEvent dialogTerminatedEvent) {
    }
New to GrepCode? Check out our FAQ X