Exemplo n.º 1
0
  public void processCancel(RequestEvent requestEvent, ServerTransaction serverTransactionId) {
    Request request = requestEvent.getRequest();
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    try {
      logger.info("shootme:  got a cancel. ");
      // Because this is not an In-dialog request, you will get a null server Tx id here.
      if (serverTransactionId == null) {
        serverTransactionId = sipProvider.getNewServerTransaction(request);
      }
      Response response = protocolObjects.messageFactory.createResponse(200, request);
      serverTransactionId.sendResponse(response);

      String serverTxId = ((ViaHeader) response.getHeader(ViaHeader.NAME)).getBranch();
      ServerTransaction serverTx = (ServerTransaction) this.serverTxTable.get(serverTxId);
      if (serverTx != null
          && (serverTx.getState().equals(TransactionState.TRYING)
              || serverTx.getState().equals(TransactionState.PROCEEDING))) {
        Request originalRequest = serverTx.getRequest();
        Response resp =
            protocolObjects.messageFactory.createResponse(
                Response.REQUEST_TERMINATED, originalRequest);
        serverTx.sendResponse(resp);
      }

    } catch (Exception ex) {
      ex.printStackTrace();
      System.exit(0);
    }
  }
Exemplo n.º 2
0
  private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid) {
    try {
      logger.info("sendInviteOK: " + inviteTid);
      if (inviteTid.getState() != TransactionState.COMPLETED) {
        logger.info("shootme: Dialog state before OK: " + inviteTid.getDialog().getState());

        SipProvider sipProvider = (SipProvider) requestEvent.getSource();
        Request request = requestEvent.getRequest();
        Response okResponse = protocolObjects.messageFactory.createResponse(Response.OK, request);
        ListeningPoint lp = sipProvider.getListeningPoint(protocolObjects.transport);
        int myPort = lp.getPort();

        Address address =
            protocolObjects.addressFactory.createAddress(
                "Shootme <sip:" + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = protocolObjects.headerFactory.createContactHeader(address);
        okResponse.addHeader(contactHeader);
        inviteTid.sendResponse(okResponse);
        logger.info("shootme: Dialog state after OK: " + inviteTid.getDialog().getState());
        TestHarness.assertEquals(DialogState.CONFIRMED, inviteTid.getDialog().getState());
      } else {
        logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 3
0
  public boolean isLastRequestUncommited() {
    if (_indexLastReadRequest >= _receivedRequests.size()) return false;

    ServerTransaction tx = _receivedRequests.get(_indexLastReadRequest).getServerTransaction();
    return tx.getState() != TransactionState.COMPLETED
        && tx.getState() != TransactionState.TERMINATED;
  }
Exemplo n.º 4
0
 private void sendInviteOK() {
   try {
     if (inviteTid.getState() != TransactionState.COMPLETED) {
       System.out.println("shootme: Dialog state before 486: " + inviteTid.getDialog().getState());
       inviteTid.sendResponse(okResponse);
       System.out.println("shootme: Dialog state after 486: " + inviteTid.getDialog().getState());
     }
   } catch (SipException ex) {
     ex.printStackTrace();
   } catch (InvalidArgumentException ex) {
     ex.printStackTrace();
   }
 }
  /** {@inheritDoc} */
  public void dispatchMessage(
      final SipProvider sipProvider, SipServletMessageImpl sipServletMessage)
      throws DispatcherException {
    //		final SipNetworkInterfaceManager sipNetworkInterfaceManager =
    // sipApplicationDispatcher.getSipNetworkInterfaceManager();
    final SipServletRequestImpl sipServletRequest = (SipServletRequestImpl) sipServletMessage;
    if (logger.isInfoEnabled()) {
      logger.info("Routing of Cancel Request " + sipServletRequest);
    }
    /*
     * WARNING: routing of CANCEL is special because CANCEL does not contain Route headers as other requests related
     * to the dialog. But still it has to be routed through the app path
     * of the INVITE
     */
    /* If there is a proxy with the request, let's try to send it directly there.
     * This is needed because of CANCEL which is a subsequent request that might
     * not have Routes. For example if the callee has'n responded the caller still
     * doesn't know the route-record and just sends cancel to the outbound proxy.
     */
    //		boolean proxyCancel = false;
    ServerTransaction cancelTransaction = (ServerTransaction) sipServletRequest.getTransaction();

    if (cancelTransaction != null
        && !TransactionState.TERMINATED.equals(cancelTransaction.getState())) {
      if (logger.isDebugEnabled()) {
        logger.debug("Sending 200 to Cancel " + sipServletRequest);
      }
      try {
        // First we need to send OK ASAP because of retransmissions both for
        // proxy or app
        SipServletResponseImpl cancelResponse =
            (SipServletResponseImpl) sipServletRequest.createResponse(200, "Canceling");
        Response cancelJsipResponse = (Response) cancelResponse.getMessage();
        cancelTransaction.sendResponse(cancelJsipResponse);
      } catch (SipException e) {
        throw new DispatcherException(
            Response.SERVER_INTERNAL_ERROR, "Impossible to send the ok to the CANCEL", e);
      } catch (InvalidArgumentException e) {
        throw new DispatcherException(
            Response.SERVER_INTERNAL_ERROR, "Impossible to send the ok to the CANCEL", e);
      }
      if (logger.isDebugEnabled()) {
        logger.debug("checking what to do with the CANCEL " + sipServletRequest);
      }
      DispatchTask dispatchTask = new CancelDispatchTask(sipServletRequest, sipProvider);
      // Execute CANCEL without waiting for previous requests because if we wait for an INVITE to
      // complete
      // all responses will be already sent by the time the CANCEL is out of the queue.
      this.sipApplicationDispatcher.getAsynchronousExecutor().execute(dispatchTask);
    } else {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Retransmission received for CANCEL "
                + sipServletRequest
                + ", transaction "
                + cancelTransaction);
        if (cancelTransaction != null) {
          logger.debug("Cancel Transaction state " + cancelTransaction.getState());
        }
      }
    }
  }