Exemplo n.º 1
0
  /** Process the invite request. */
  public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction) {
    try {
      // System.out.println("ProcessInvite");
      Request request = requestEvent.getRequest();
      SipProvider sipProvider = (SipProvider) requestEvent.getSource();
      // Note you need to create the Server Transaction
      // before the listener returns but you can delay sending the response

      ServerTransaction st = sipProvider.getNewServerTransaction(request);
      if (transactionIDs.containsKey(st.getBranchId())) {
        System.out.println(
            "OOOPS -- seen this guy before!! This must be a late guy "
                + st.getBranchId()
                + " st = "
                + transactionIDs.get(st.getBranchId()));
        return;
      } else {
        transactionIDs.put(st.getBranchId(), st);
      }

      TTask ttask = new TTask(requestEvent, st);
      int ttime;
      if ((numInvite % 4) == 0) ttime = 5000;
      else if ((numInvite % 4) == 1) ttime = 1000;
      else ttime = 300;
      numInvite++;
      new Timer().schedule(ttask, ttime);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 2
0
  /** Process the invite request. */
  public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction) {
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    Request request = requestEvent.getRequest();
    try {
      System.out.println("b2bua: got an Invite sending Trying");
      ServerTransaction st = requestEvent.getServerTransaction();
      if (st == null) {
        st = sipProvider.getNewServerTransaction(request);
      }
      Dialog dialog = st.getDialog();

      ToHeader to = (ToHeader) request.getHeader(ToHeader.NAME);
      SipURI toUri = (SipURI) to.getAddress().getURI();

      SipURI target = registrar.get(toUri.getUser());

      if (target == null) {
        System.out.println("User " + toUri + " is not registered.");
        throw new RuntimeException("User not registered " + toUri);
      } else {
        ClientTransaction otherLeg = call(target);
        otherLeg.setApplicationData(st);
        st.setApplicationData(otherLeg);
        dialog.setApplicationData(otherLeg.getDialog());
        otherLeg.getDialog().setApplicationData(dialog);
      }

    } catch (Exception ex) {
      ex.printStackTrace();
      System.exit(0);
    }
  }
Exemplo n.º 3
0
 public void processRegister(RequestEvent requestEvent, ServerTransaction serverTransactionId) {
   Request request = requestEvent.getRequest();
   ContactHeader contact = (ContactHeader) request.getHeader(ContactHeader.NAME);
   SipURI contactUri = (SipURI) contact.getAddress().getURI();
   FromHeader from = (FromHeader) request.getHeader(FromHeader.NAME);
   SipURI fromUri = (SipURI) from.getAddress().getURI();
   registrar.put(fromUri.getUser(), contactUri);
   try {
     Response response = this.messageFactory.createResponse(200, request);
     ServerTransaction serverTransaction = sipProvider.getNewServerTransaction(request);
     serverTransaction.sendResponse(response);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }