コード例 #1
0
    public void start() throws IllegalStateException {

      SipFactory sipFactory = null;
      sipStack = null;

      Properties properties = new Properties();
      properties.setProperty("javax.sip.RETRANSMISSION_FILTER", "true");
      properties.setProperty("javax.sip.STACK_NAME", "StatelessForwarder");
      properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");
      // 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", "32");
      properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "./logs/statelessforwarderdebug.txt");
      properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "./logs/statelessforwarderlog.xml");

      try {
        // Create SipStack object
        sipFactory = SipFactory.getInstance();
        sipFactory.setPathName("gov.nist");
        sipStack = sipFactory.createSipStack(properties);

        headerFactory = sipFactory.createHeaderFactory();
        addressFactory = sipFactory.createAddressFactory();
        messageFactory = sipFactory.createMessageFactory();

        ListeningPoint lp = sipStack.createListeningPoint(myHost, myPort, ListeningPoint.UDP);
        sipProvider = sipStack.createSipProvider(lp);
        sipProvider.addSipListener(this);

        sipStack.start();
      } catch (Exception ex) {
        throw new IllegalStateException(
            "Cant create sip objects and lps due to[" + ex.getMessage() + "]", ex);
      }
    }
コード例 #2
0
    public void init() {
      SipFactory sipFactory = null;
      sipStack = null;
      sipFactory = SipFactory.getInstance();
      sipFactory.setPathName("org.mobicents.ha");
      Properties properties = new Properties();
      properties.setProperty("javax.sip.STACK_NAME", stackName);
      // properties.setProperty("javax.sip.OUTBOUND_PROXY", Integer
      //                .toString(BALANCER_PORT));
      // 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", "32");
      properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "logs/" + stackName + "debug.txt");
      properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "logs/" + stackName + "log.xml");

      try {
        // Create SipStack object
        sipStack = sipFactory.createSipStack(properties);
        System.out.println("sipStack = " + sipStack);
      } catch (PeerUnavailableException e) {
        // could not find
        // gov.nist.jain.protocol.ip.sip.SipStackImpl
        // in the classpath
        e.printStackTrace();
        System.err.println(e.getMessage());
        if (e.getCause() != null) e.getCause().printStackTrace();
        System.exit(0);
      }

      try {
        headerFactory = sipFactory.createHeaderFactory();
        addressFactory = sipFactory.createAddressFactory();
        messageFactory = sipFactory.createMessageFactory();
        ListeningPoint lp = sipStack.createListeningPoint(myAddress, myPort, ListeningPoint.UDP);

        Shootme listener = this;

        sipProvider = sipStack.createSipProvider(lp);
        System.out.println("udp provider " + sipProvider);
        sipProvider.addSipListener(listener);
        //                if(dialogs != null) {
        //                    Collection<Dialog> serializedDialogs =
        // simulateDialogSerialization(dialogs);
        //                    for (Dialog dialog : serializedDialogs) {
        //                        ((SIPDialog)dialog).setSipProvider((SipProviderImpl)sipProvider);
        //                        ((SipStackImpl)sipStack).putDialog((SIPDialog)dialog);
        //                    }
        //                    this.dialog = (SIPDialog)serializedDialogs.iterator().next();
        //                }
        sipStack.start();
        if (!callerSendsBye && this.dialog != null) {
          try {
            Request byeRequest = this.dialog.createRequest(Request.BYE);
            ClientTransaction ct = sipProvider.getNewClientTransaction(byeRequest);
            System.out.println("sending BYE " + byeRequest);
            dialog.sendRequest(ct);
          } catch (Exception ex) {
            ex.printStackTrace();
            fail("Unexpected exception ");
          }
        }
      } catch (Exception ex) {
        System.out.println(ex.getMessage());
        ex.printStackTrace();
        fail("Unexpected exception");
      }
    }