Examples of RequestEvent


Examples of javax.sip.RequestEvent

                return;
            }

        }

        RequestEvent sipEvent;

        if (sipStack.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
            sipStack.getStackLogger().logDebug(
                    sipRequest.getMethod() + " transaction.isMapped = "
                            + transaction.isTransactionMapped());
        }

        /*
         * RFC 3265: Each event package MUST specify whether forked SUBSCRIBE
         * requests are allowed to install multiple subscriptions. If such
         * behavior is not allowed, the first potential dialog- establishing
         * message will create a dialog. All subsequent NOTIFY messages which
         * correspond to the SUBSCRIBE message (i.e., match "To", "From", "From"
         * header "tag" parameter, "Call-ID", "CSeq", "Event", and "Event"
         * header "id" parameter) but which do not match the dialog would be
         * rejected with a 481 response. Note that the 200-class response to the
         * SUBSCRIBE can arrive after a matching NOTIFY has been received; such
         * responses might not correlate to the same dialog established by the
         * NOTIFY. Except as required to complete the SUBSCRIBE transaction,
         * such non-matching 200-class responses are ignored.
         */

        if (dialog == null && sipRequestMethod.equals(Request.NOTIFY)) {

            SIPClientTransaction pendingSubscribeClientTx = sipStack
                    .findSubscribeTransaction(sipRequest, listeningPoint);

            if (sipStack.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
                sipStack.getStackLogger().logDebug(
                        "PROCESSING NOTIFY  DIALOG == null "
                                + pendingSubscribeClientTx);
            }

            /*
             * RFC 3265: Upon receiving a NOTIFY request, the subscriber should
             * check that it matches at least one of its outstanding
             * subscriptions; if not, it MUST return a
             * "481 Subscription does not exist" response unless another 400- or
             * -class response is more appropriate.
             */
            if (sipProvider.isAutomaticDialogSupportEnabled()
                    && pendingSubscribeClientTx == null
                    && !sipStack.isDeliverUnsolicitedNotify()) {
                /*
                 * This is the case of the UAC receiving a Stray NOTIFY for
                 * which it has not previously sent out a SUBSCRIBE and for
                 * which it does not have an established dialog.
                 */
                try {
                    if (sipStack.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
                        sipStack.getStackLogger().logDebug(
                                "Could not find Subscription for Notify Tx.");
                    }
                    Response errorResponse = sipRequest
                            .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);
                    errorResponse
                            .setReasonPhrase("Subscription does not exist");
                    sipProvider.sendResponse(errorResponse);
                    return;

                } catch (Exception ex) {
                    sipStack
                            .getStackLogger()
                            .logError(
                                    "Exception while sending error response statelessly",
                                    ex);
                    return;
                }

            }

            // If the server transaction cannot be found or if it
            // aleady has a dialog attached to it then just assign the
            // notify to this dialog and pass it up.
            if (pendingSubscribeClientTx != null) {
                // The response to the pending subscribe tx can try to create
                // a dialog at the same time that the notify is trying to
                // create a dialog. Thus we cannot process both at the
                // same time.

                transaction.setPendingSubscribe(pendingSubscribeClientTx);
                // The transaction gets assigned to the dialog from the
                // outgoing subscribe. First see if anybody claimed the
                // default Dialog for the outgoing Subscribe request.
                SIPDialog subscriptionDialog = (SIPDialog) pendingSubscribeClientTx
                        .getDefaultDialog();

                // TODO -- refactor this. Can probably be written far cleaner.
                if (subscriptionDialog == null
                        || subscriptionDialog.getDialogId() == null
                        || !subscriptionDialog.getDialogId().equals(dialogId)) {
                    // Notify came in before you could assign a response to
                    // the subscribe.
                    // grab the default dialog and assign it to the tags in
                    // the notify.
                    if (subscriptionDialog != null
                            && subscriptionDialog.getDialogId() == null) {
                        subscriptionDialog.setDialogId(dialogId);

                    } else {
                        subscriptionDialog = pendingSubscribeClientTx
                                .getDialog(dialogId);
                    }
                    if (sipStack.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
                        sipStack.getStackLogger().logDebug(
                                "PROCESSING NOTIFY Subscribe DIALOG "
                                        + subscriptionDialog);
                    }

                    // The user could have createed a dialog before sending out
                    // the SUBSCRIBE on the subscribe tx.
                    if (subscriptionDialog == null
                            && (sipProvider.isAutomaticDialogSupportEnabled() || pendingSubscribeClientTx
                                    .getDefaultDialog() != null)) {
                        Event event = (Event) sipRequest
                                .getHeader(EventHeader.NAME);
                        if (sipStack.isEventForked(event.getEventType())) {

                            subscriptionDialog = SIPDialog.createFromNOTIFY(
                                    pendingSubscribeClientTx, transaction);

                        }

                    }
                    if (subscriptionDialog != null) {
                        transaction.setDialog(subscriptionDialog, dialogId);
                        if (subscriptionDialog.getState() != DialogState.CONFIRMED) {
                            subscriptionDialog
                                    .setPendingRouteUpdateOn202Response(sipRequest);

                        }
                        subscriptionDialog.setState(DialogState.CONFIRMED
                                .getValue());
                        sipStack.putDialog(subscriptionDialog);
                        pendingSubscribeClientTx.setDialog(subscriptionDialog,
                                dialogId);
                        if (!transaction.isTransactionMapped()) {
                            this.sipStack.mapTransaction(transaction);
                            // Let the listener see it if it just got
                            // created.
                            // otherwise, we have already processed the tx
                            // so
                            // we dont want the listener to see it.
                            transaction.setPassToListener();
                            try {
                                this.sipStack.addTransaction(transaction);
                            } catch (Exception ex) {
                            }
                        }
                    }
                } else {
                    // The subscription default dialog is our dialog.
                    // Found a subscrbe dialog for the NOTIFY
                    // So map the tx.
                    transaction.setDialog(subscriptionDialog, dialogId);
                    dialog = subscriptionDialog;
                    if (!transaction.isTransactionMapped()) {
                        this.sipStack.mapTransaction(transaction);
                        // Let the listener see it if it just got created.
                        // otherwise, we have already processed the tx so
                        // we dont want the listener to see it.
                        transaction.setPassToListener();
                        try {
                            this.sipStack.addTransaction(transaction);
                        } catch (Exception ex) {
                        }
                    }
                    sipStack.putDialog(subscriptionDialog);
                    if (pendingSubscribeClientTx != null) {
                        subscriptionDialog
                                .addTransaction(pendingSubscribeClientTx);
                        pendingSubscribeClientTx.setDialog(subscriptionDialog,
                                dialogId);

                    }
                }
                if (transaction != null
                        && ((SIPServerTransaction) transaction)
                                .isTransactionMapped()) {
                    // Shadow transaction has been created and the stack
                    // knows
                    // about it.
                    sipEvent = new RequestEvent((SipProvider) sipProvider,
                            (ServerTransaction) transaction,
                            subscriptionDialog, (Request) sipRequest);
                } else {
                    /*
                     * Shadow transaction has been created but the stack does
                     * not know about it.
                     */
                    sipEvent = new RequestEvent((SipProvider) sipProvider,
                            null, subscriptionDialog, (Request) sipRequest);
                }

            } else {
                if (sipStack.isLoggingEnabled(LogLevels.TRACE_DEBUG)) {
                    sipStack.getStackLogger().logDebug(
                            "could not find subscribe tx");
                }

                // Got a notify out of the blue - just pass it up
                // for stateless handling by the application.
                sipEvent = new RequestEvent(sipProvider, null, null,
                        (Request) sipRequest);
            }

        } else {

            // For a dialog creating event - set the transaction to null.
            // The listener can create the dialog if needed.
            if (transaction != null
                    && (((SIPServerTransaction) transaction)
                            .isTransactionMapped())) {
                sipEvent = new RequestEvent(sipProvider,
                        (ServerTransaction) transaction, dialog,
                        (Request) sipRequest);
            } else {
                sipEvent = new RequestEvent(sipProvider, null, dialog,
                        (Request) sipRequest);
            }
        }
        sipProvider.handleEvent(sipEvent, transaction);

View Full Code Here

Examples of javax.sip.RequestEvent

        //   print the trace provided by the base-class.
        super.processRequest(requestEvent);
       
        try
        {
            RequestEvent req_event = requestEvent.getRequestEvent();
            Request req_msg = req_event.getRequest();
            SipProvider provider = (SipProvider) req_event.getSource();

            JipletSession session = null;
            if (req_msg.getMethod().equals(Request.INVITE) == true)
            {
                session = requestEvent.getSession(true);
View Full Code Here

Examples of javax.sip.RequestEvent

            if (timer == null)
            {
                timer = startTimer(60000L, true, requestEvent, null);
            }

            RequestEvent req_event = requestEvent.getRequestEvent();
            SipProvider provider = (SipProvider) req_event.getSource();
            Request req_msg = req_event.getRequest();

            FromHeader from = (FromHeader) req_msg.getHeader(FromHeader.NAME);

            long expires = 60L * 60L * 1000L; // default 60 minutes
           
View Full Code Here

Examples of javax.sip.RequestEvent

        subscriptionList.dispose();
    }

    public void doExtension(JipletRequest request)
    {
        RequestEvent event = request.getRequestEvent();

        try
        {
            if (event.getRequest().getMethod().equals("PUBLISH") == true)
            {
                if (isDebugEnabled() == true)
                {
                    debug("SipPresence: Received PUBLISH message: \n"
                            + event.getRequest().toString());
                }

                // check event type, store this message in subscriptionList for
                // presentity status, ignore if cseq <= last one from this
                // subscriber
                // can use this info when sending notify (if pidf), also remove
                // from
                // subscriptionList
                // when presentity unregisters

                try
                {
                    Response response = getMessageFactory().createResponse(
                            Response.OK, event.getRequest());
                    sendResponse(event, response);
                }
                catch (Exception e)
                {
                    error("A PUBLISH message could not be processed because an exception occured.\n"
View Full Code Here

Examples of javax.sip.RequestEvent

                    null);
        }

        try
        {
            RequestEvent event = requestEvent.getRequestEvent();
            Request request = event.getRequest();

            if (isDebugEnabled() == true)
            {
                debug("SipPresence: Received SUBSCRIBE: " + request);
            }

            // look at the event header first
            EventHeader ev_hdr = (EventHeader) request
                    .getHeader(EventHeader.NAME);
            if (eventHeaderValid(request, ev_hdr) == false)
            {
                // 489 Bad Event, debug msg already output
                Response response = getMessageFactory().createResponse(
                        Response.BAD_EVENT, request);
                sendResponse(event, response);
                return;
            }

            if (ev_hdr.getEventType().equals("presence.winfo") == true)
            {
                // watcher info placeholder - we don't support this package
                Response response = getMessageFactory().createResponse(
                        Response.BAD_EVENT, request);
                sendResponse(event, response);
                return;
            }

            // determine the duration
            int duration = DEFAULT_SUBSCRIBE_DURATION;
            ExpiresHeader exp = (ExpiresHeader) request
                    .getHeader(ExpiresHeader.NAME);
            if (exp != null)
            {
                duration = exp.getExpires();
            }

            // find the active subscription (if exists) for this message
            Subscription sub = subscriptionList.findSubscription(request);

            if (sub != null)
            {
                if (duration > 0)
                {
                    refresh(event, sub, duration);
                    return;
                }

                // this is an unsubscribe
                try
                {
                    unsubscribe(event, sub, duration);
                }
                catch (Exception e)
                {
                    error("A SUBSCRIBE message could not be processed because an exception occured.\n"
                            + e.getClass().getName()
                            + ": "
                            + e.getMessage()
                            + "\n" + JipletLogger.getStackTrace(e));
                }

                // drop the subscription
                subscriptionList.removeSubscription(sub);
                sub.dispose();

                return;
            }

            // new subscription

            int response_code = Response.OK;
            String reason = "OK";
            String state = SubscriptionStateHeader.ACTIVE;

            // send the response right away
            String to_tag = new Long(Calendar.getInstance().getTimeInMillis())
                    .toString();
            Response response = createResponse(response_code, reason, to_tag,
                    request, duration);
            ServerTransaction transaction = sendResponse(event, response);

            if (transaction == null)
            {
                // stack couldn't give us a dialog
                return;
            }
            Dialog dialog = transaction.getDialog();

            sub = new Subscription(this, subscriptionList, SubscriptionList
                    .getSubscriptionId(request), ev_hdr.getEventId(), ev_hdr
                    .getEventType(), ((FromHeader) request
                    .getHeader(FromHeader.NAME)).getAddress(),
                    ((ToHeader) request.getHeader(ToHeader.NAME)).getAddress(),
                    to_tag);
            sub.setDialog(dialog);
            sub.setSubscriptionState(state);
            sub.setTimeLeft(duration);

            if (duration == 0) // it's a fetch or contact was removed from the
            // phone
            {
                sub.setTerminationReason("Presence Fetch");
                sub.setSubscriptionState(SubscriptionStateHeader.TERMINATED);
            }
            else
            {
                subscriptionList.addSubscription(sub);
            }

            sub.sendNotify((SipProvider) event.getSource());
        }
        catch (Exception e)
        {
            error("A SUBSCRIBE message could not be processed because an exception occured.\n"
                    + e.getClass().getName()
View Full Code Here

Examples of javax.sip.RequestEvent

                  return;
              }
 
          }
 
          RequestEvent sipEvent;
 
          if (sipStack.isLoggingEnabled()) {
              sipStack.getStackLogger().logDebug(
                      sipRequest.getMethod() + " transaction.isMapped = "
                              + transaction.isTransactionMapped());
          }
 
          /*
           * RFC 3265: Each event package MUST specify whether forked SUBSCRIBE requests are allowed
           * to install multiple subscriptions. If such behavior is not allowed, the first potential
           * dialog- establishing message will create a dialog. All subsequent NOTIFY messages which
           * correspond to the SUBSCRIBE message (i.e., match "To", "From", "From" header "tag"
           * parameter, "Call-ID", "CSeq", "Event", and "Event" header "id" parameter) but which do
           * not match the dialog would be rejected with a 481 response. Note that the 200-class
           * response to the SUBSCRIBE can arrive after a matching NOTIFY has been received; such
           * responses might not correlate to the same dialog established by the NOTIFY. Except as
           * required to complete the SUBSCRIBE transaction, such non-matching 200-class responses
           * are ignored.
           */
 
          if (dialog == null && sipRequestMethod.equals(Request.NOTIFY)) {
 
              SIPClientTransaction pendingSubscribeClientTx = sipStack.findSubscribeTransaction(
                      sipRequest, listeningPoint);
 
              if (sipStack.isLoggingEnabled()) {
                  sipStack.getStackLogger().logDebug(
                          "PROCESSING NOTIFY  DIALOG == null " + pendingSubscribeClientTx);
              }
 
              /*
               * RFC 3265: Upon receiving a NOTIFY request, the subscriber should check that it
               * matches at least one of its outstanding subscriptions; if not, it MUST return a
               * "481 Subscription does not exist" response unless another 400- or -class response
               * is more appropriate.
               */
              if (sipProvider.isAutomaticDialogSupportEnabled() && pendingSubscribeClientTx == null
                      && !sipStack.isDeliverUnsolicitedNotify()) {
                  /*
                   * This is the case of the UAC receiving a Stray NOTIFY for which it has not
                   * previously sent out a SUBSCRIBE and for which it does not have an established
                   * dialog.
                   */
                  try {
                      if (sipStack.isLoggingEnabled()) {
                          sipStack.getStackLogger().logDebug(
                                  "Could not find Subscription for Notify Tx.");
                      }
                      Response errorResponse = sipRequest
                              .createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST);
                      errorResponse.setReasonPhrase("Subscription does not exist");
                      sipProvider.sendResponse(errorResponse);
                      return;
 
                  } catch (Exception ex) {
                      sipStack.getStackLogger().logError(
                              "Exception while sending error response statelessly", ex);
                      return;
                  }
 
              }
 
              // If the server transaction cannot be found or if it
              // aleady has a dialog attached to it then just assign the
              // notify to this dialog and pass it up.
              if (pendingSubscribeClientTx != null) {
                  // The response to the pending subscribe tx can try to create
                  // a dialog at the same time that the notify is trying to
                  // create a dialog. Thus we cannot process both at the
                  // same time.
 
                  transaction.setPendingSubscribe(pendingSubscribeClientTx);
                  // The transaction gets assigned to the dialog from the
                  // outgoing subscribe. First see if anybody claimed the
                  // default Dialog for the outgoing Subscribe request.
                  SIPDialog subscriptionDialog = (SIPDialog) pendingSubscribeClientTx
                          .getDefaultDialog();
 
                  // TODO -- refactor this. Can probably be written far cleaner.
                  if (subscriptionDialog == null || subscriptionDialog.getDialogId() == null
                          || !subscriptionDialog.getDialogId().equals(dialogId)) {
                      // Notify came in before you could assign a response to
                      // the subscribe.
                      // grab the default dialog and assign it to the tags in
                      // the notify.
                      if (subscriptionDialog != null && subscriptionDialog.getDialogId() == null) {
                          subscriptionDialog.setDialogId(dialogId);
 
                      } else {
                          subscriptionDialog = pendingSubscribeClientTx.getDialog(dialogId);
                      }
                      if (sipStack.isLoggingEnabled()) {
                          sipStack.getStackLogger().logDebug(
                                  "PROCESSING NOTIFY Subscribe DIALOG " + subscriptionDialog);
                      }
 
                      // The user could have createed a dialog before sending out
                      // the SUBSCRIBE on the subscribe tx.
                      if (subscriptionDialog == null
                              && (sipProvider.isAutomaticDialogSupportEnabled() || pendingSubscribeClientTx
                                      .getDefaultDialog() != null)) {
                          Event event = (Event) sipRequest.getHeader(EventHeader.NAME);
                          if (sipStack.isEventForked(event.getEventType())) {
 
                              subscriptionDialog = SIPDialog.createFromNOTIFY(
                                      pendingSubscribeClientTx, transaction);
 
                          }
 
                      }
                      if (subscriptionDialog != null) {
                          transaction.setDialog(subscriptionDialog, dialogId);
                          if ( subscriptionDialog.getState() != DialogState.CONFIRMED ) {
                            subscriptionDialog.setPendingRouteUpdateOn202Response(sipRequest);
                           
                          }
                          subscriptionDialog.setState(DialogState.CONFIRMED.getValue());
                          sipStack.putDialog(subscriptionDialog);
                          pendingSubscribeClientTx.setDialog(subscriptionDialog, dialogId);
                          if (!transaction.isTransactionMapped()) {
                              this.sipStack.mapTransaction(transaction);
                              // Let the listener see it if it just got
                              // created.
                              // otherwise, we have already processed the tx
                              // so
                              // we dont want the listener to see it.
                              transaction.setPassToListener();
                              try {
                                  this.sipStack.addTransaction(transaction);
                              } catch (Exception ex) {
                              }
                          }
                      }
                  } else {
                      // The subscription default dialog is our dialog.
                      // Found a subscrbe dialog for the NOTIFY
                      // So map the tx.
                      transaction.setDialog(subscriptionDialog, dialogId);
                      dialog = subscriptionDialog;
                      if (!transaction.isTransactionMapped()) {
                          this.sipStack.mapTransaction(transaction);
                          // Let the listener see it if it just got created.
                          // otherwise, we have already processed the tx so
                          // we dont want the listener to see it.
                          transaction.setPassToListener();
                          try {
                              this.sipStack.addTransaction(transaction);
                          } catch (Exception ex) {
                          }
                      }
                      sipStack.putDialog(subscriptionDialog);
                      if (pendingSubscribeClientTx != null) {
                          subscriptionDialog.addTransaction(pendingSubscribeClientTx);
                          pendingSubscribeClientTx.setDialog(subscriptionDialog, dialogId);
 
                      }
                  }
                  if (transaction != null
                          && ((SIPServerTransaction) transaction).isTransactionMapped()) {
                      // Shadow transaction has been created and the stack
                      // knows
                      // about it.
                      sipEvent = new RequestEvent((SipProvider) sipProvider,
                              (ServerTransaction) transaction, subscriptionDialog,
                              (Request) sipRequest);
                  } else {
                      // Shadow transaction has been created but the stack
                      // does
                      // not know
                      // about it.
                      sipEvent = new RequestEvent((SipProvider) sipProvider, null,
                              subscriptionDialog, (Request) sipRequest);
                  }
 
              } else {
                  if (sipStack.isLoggingEnabled()) {
                      sipStack.getStackLogger().logDebug("could not find subscribe tx");
                  }
 
                  // Got a notify out of the blue - just pass it up
                  // for stateless handling by the application.
                  sipEvent = new RequestEvent(sipProvider, null, null, (Request) sipRequest);
              }
 
          } else {
 
              // For a dialog creating event - set the transaction to null.
              // The listener can create the dialog if needed.
              if (transaction != null
                      && (((SIPServerTransaction) transaction).isTransactionMapped())) {
                  sipEvent = new RequestEvent(sipProvider, (ServerTransaction) transaction, dialog,
                          (Request) sipRequest);
              } else {
                  sipEvent = new RequestEvent(sipProvider, null, dialog, (Request) sipRequest);
              }
          }
          sipProvider.handleEvent(sipEvent, transaction);
      } finally {
        listeningPoint = null;
View Full Code Here

Examples of me.neatmonster.spacebukkit.events.RequestEvent

        final List<Object> arguments = (List<Object>) JSONValue.parse(argumentsString);
        try {
            if (SpaceBukkit.getInstance().actionsManager.contains(method))
                return SpaceBukkit.getInstance().actionsManager.execute(method, arguments.toArray());
            else {
                final RequestEvent event = new RequestEvent(method, arguments.toArray());
                Bukkit.getPluginManager().callEvent(event);
                return JSONValue.toJSONString(event.getResult());
            }
        } catch (final InvalidArgumentsException e) {
            e.printStackTrace();
        } catch (final UnhandledActionException e) {
            e.printStackTrace();
View Full Code Here

Examples of me.neatmonster.spacebukkit.events.RequestEvent

        List<Object> args = (List<Object>) JSONValue.parse(argsString);
            try {
                if (SpaceBukkit.getInstance().actionsManager.contains(methods.toArray()[i].toString()))
                    result.add(SpaceBukkit.getInstance().actionsManager.execute(methods.toArray()[i].toString(), args.toArray()));
                else {
                    final RequestEvent event = new RequestEvent(methods.toArray()[i].toString(), args.toArray());
                    Bukkit.getPluginManager().callEvent(event);
                    result.add(JSONValue.toJSONString(event.getResult()));
                }
            } catch (final InvalidArgumentsException e) {
              result.add(null);
                e.printStackTrace();
            } catch (final UnhandledActionException e) {
View Full Code Here

Examples of net.sacredlabyrinth.phaed.simpleclans.events.RequestEvent

                        ChatBlock.sendBlank(player);
                    }
                }
            }
        }
        SimpleClans.getInstance().getServer().getPluginManager().callEvent(new RequestEvent(req));
    }
View Full Code Here

Examples of org.glassfish.jersey.server.monitoring.RequestEvent

    }

    private void processExceptionMapperEvents() {
        final Queue<RequestEvent> eventQueue = monitoringEventListener.getExceptionMapperEvents();
        while (!eventQueue.isEmpty()) {
            final RequestEvent event = eventQueue.remove();
            final ExceptionMapperStatisticsImpl.Builder mapperStats = statisticsBuilder.getExceptionMapperStatisticsBuilder();

            if (event.getExceptionMapper() != null) {
                mapperStats.addExceptionMapperExecution(event.getExceptionMapper().getClass(), 1);
            }

            mapperStats.addMapping(event.isResponseSuccessfullyMapped(), 1);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.