/*
Implements synchronous sending of event generating actions.
345139
public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action, long timeout)
            throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException
    {
        final ResponseEventsImpl responseEvents;
        final ResponseEventHandler responseEventHandler;
        final String internalActionId;

        if (action == null)
        {
            throw new IllegalArgumentException("Unable to send action: action is null.");
        }
        else if (action.getActionCompleteEventClass() == null)
        {
            throw new IllegalArgumentException(
                    "Unable to send action: actionCompleteEventClass for " + action.getClass().getName() + " is null.");
        }
        else if (!ResponseEvent.class.isAssignableFrom(action.getActionCompleteEventClass()))
        {
            throw new IllegalArgumentException(
                    "Unable to send action: actionCompleteEventClass (" + action.getActionCompleteEventClass().getName()
                            + ") for " + action.getClass().getName() + " is not a ResponseEvent.");
        }

        if (state != CONNECTED)
        {
            throw new IllegalStateException(
                    "Actions may only be sent when in state " + "CONNECTED but connection is in state " + state);
        }

        responseEvents = new ResponseEventsImpl();
        responseEventHandler = new ResponseEventHandler(responseEvents, action.getActionCompleteEventClass());

        internalActionId = createInternalActionId();

        try
        {
            // register response handler...
            synchronized (this.responseListeners)
            {
                this.responseListeners.put(internalActionId, responseEventHandler);
            }

            // ...and event handler.
            synchronized (this.responseEventListeners)
            {
                this.responseEventListeners.put(internalActionId, responseEventHandler);
            }

            writer.sendAction(action, internalActionId);
            // only wait if response has not yet arrived.
            if (responseEvents.getResponse() == null || !responseEvents.isComplete())
            {
                try
                {
                    responseEvents.await(timeout);
                }
                catch (InterruptedException e)
                {
                    logger.warn("Interrupted while waiting for response events.");
                    Thread.currentThread().interrupt();
                }
            }

            // still no response or not all events received and timed out?
            if (responseEvents.getResponse() == null || !responseEvents.isComplete())
            {
                throw new EventTimeoutException(
                        "Timeout waiting for response or response events to " + action.getAction()
                                + (action.getActionId() == null ? "" : " (actionId: " + action.getActionId() + ")"),
                        responseEvents);
            }

        }
        finally
        {
            // remove the event handler
            synchronized (this.responseEventListeners)
            {
                this.responseEventListeners.remove(internalActionId);
            }

            // Note: The response handler should have already been removed
            // when the response was received, however we remove it here
            // just in case it was never received.
            synchronized (this.responseListeners)
            {
                this.responseListeners.remove(internalActionId);
            }

        }

        return responseEvents;
    }
71801
protected synchronized void fireOutputChangeEvent(OUTPUT_EVENT event) {
        OutputChangeEvent oce = new OutputChangeEvent(this, event);

        for (OutputChangeListener pcl : outputListeners) {
            pcl.outputChanged(oce);
        }
    }
1303092
public void onPost(String triggeredByUser) {
        onPost(GitHubTriggerEvent.create()
                .withOrigin(SCMEvent.originOf(Stapler.getCurrentRequest()))
                .withTriggeredByUser(triggeredByUser)
                .build()
        );
    }
874153
function () {
    clearTimeout(timeoutId);
    var args = [];
    for (var index = 0, length = arguments.length; index < length; index++) {
      args.push(arguments[index]);
    }
    self.socketEvent = {
      namespace: action.namespace,
      eventType: action.eventType,
      args: args
    };
    callback(null, self.socketEvent);
  }
43080
function(syncAction){
    var oldAction = this.syncAction;

    if (typeof syncAction != 'function')
      syncAction = null;

    this.syncAction = syncAction;

    if (syncAction)
    {
      if (!oldAction)
        this.addHandler(this.syncEvents);
      if (this.isSyncRequired())
        callSyncAction(this);
    }
    else
    {
      if (oldAction)
        this.removeHandler(this.syncEvents);
    }
  }
151567
private void sendSolutionActions(String action, String reqId){
        if(reqId!=null && !reqId.equals("")) {
            Map<String, String> map = Maps.newHashMap();
            map.put("action", action);
            map.put("reqid", reqId);
            this.sendEvent(map);
        }
    }
38574
function send() {
    var args = slice.call(arguments), events = this.events, handled;

    if (!this.__isCurrent__) {
      throw new Error('State#send: attempted to send an event to a state that is not current: ' + this);
    }

    if (this === this.root()) {
      trace.call(this, 'State: [EVENT]  : ' + args[0]);
    }

    handled = this.concurrent ? sendConcurrent.apply(this, arguments) :
      sendClustered.apply(this, arguments);

    if (!handled && typeof events[args[0]] === 'function') {
      this.__isSending__ = true;
      handled = !!events[args[0]].apply(this, args.slice(1));
      this.__isSending__ = false;
    }

    if (!this.superstate) { transition.call(this); }

    return handled;
  }
718682
public void dispatchEvent(Event event, String eventName) {
    int typeInt = Event.getTypeInt(eventName);
    Object[] handlerData = $(element).data(EVENT_DATA);
    for (int i = 0, l = elementEvents.length(); i < l; i++) {
      BindFunction listener = elementEvents.get(i);
      String namespace = JsUtils.prop(event, "namespace");
      boolean matchEV = listener != null && (listener.hasEventType(typeInt) || listener.isTypeOf(eventName));
      boolean matchNS = matchEV && (isNullOrEmpty(namespace) || listener.nameSpace.equals(namespace));
      if (matchEV && matchNS) {
        if (!listener.fire(event, typeInt, eventName, handlerData)) {
          event.stopPropagation();
          event.preventDefault();
        }
      }
    }
  }
516905
private void sendEvent(Event event, ComponentDescriptor<?> descriptor, ComponentManager componentManager)
    {
        if (this.observationManager != null) {
            this.observationManager.notify(event, componentManager, descriptor);
        }
    }
1214731
function () {
            Dialog.superclass.initEvents.call(this);

            var SIGNATURE = CustomEvent.LIST;

            /**
            * CustomEvent fired prior to submission
            * @event beforeSubmitEvent
            */ 
            this.beforeSubmitEvent = 
                this.createEvent(EVENT_TYPES.BEFORE_SUBMIT);
            this.beforeSubmitEvent.signature = SIGNATURE;
            
            /**
            * CustomEvent fired after submission
            * @event submitEvent
            */
            this.submitEvent = this.createEvent(EVENT_TYPES.SUBMIT);
            this.submitEvent.signature = SIGNATURE;
        
            /**
            * CustomEvent fired for manual submission, before the generic submit event is fired
            * @event manualSubmitEvent
            */
            this.manualSubmitEvent = 
                this.createEvent(EVENT_TYPES.MANUAL_SUBMIT);
            this.manualSubmitEvent.signature = SIGNATURE;

            /**
            * CustomEvent fired after asynchronous submission, before the generic submit event is fired
            *
            * @event asyncSubmitEvent
            * @param {Object} conn The connection object, returned by YAHOO.util.Connect.asyncRequest
            */
            this.asyncSubmitEvent = this.createEvent(EVENT_TYPES.ASYNC_SUBMIT);
            this.asyncSubmitEvent.signature = SIGNATURE;

            /**
            * CustomEvent fired after form-based submission, before the generic submit event is fired
            * @event formSubmitEvent
            */
            this.formSubmitEvent = this.createEvent(EVENT_TYPES.FORM_SUBMIT);
            this.formSubmitEvent.signature = SIGNATURE;

            /**
            * CustomEvent fired after cancel
            * @event cancelEvent
            */
            this.cancelEvent = this.createEvent(EVENT_TYPES.CANCEL);
            this.cancelEvent.signature = SIGNATURE;
        
        }
888718
@Override
    public void sendEvents(TreeSet<Event> events) {
        if (events == null) {
            throw new IllegalArgumentException("Events must be not null");
        }
        if (events.isEmpty()) {
            return;
        }

        addEvents(events);

        if (distributed) {
            partitionManager.notifyEvents(new ArrayList<>(events));
        }
    }
625796
public void sendEventsFromQueue() {
        if (null == queue || stopSending) {
            return;
        }
        LOG.fine("Scheduler called for sending events");

        int packageSize = getEventsPerMessageCall();

        while (!queue.isEmpty()) {
            final List<Event> list = new ArrayList<Event>();
            int i = 0;
            while (i < packageSize && !queue.isEmpty()) {
                Event event = queue.remove();
                if (event != null && !filter(event)) {
                    list.add(event);
                    i++;
                }
            }
            if (list.size() > 0) {
                executor.execute(new Runnable() {
                    public void run() {
                        try {
                            sendEvents(list);
                        } catch (MonitoringException e) {
                            e.logException(Level.SEVERE);
                        }
                    }
                });

            }
        }

    }
813872
void fireEvent() {
        boolean useLock = !isReentrant();
        if (useLock) {
            lock.lock();
        }
        EventImpl event = eventQueue.poll();

        try {
            if (event != null) {
                fireEvent(event);
            }
        } finally {
            if (useLock) {
                lock.unlock();
            }
        }

    }
696043
public  void  execute() throws ActivityException{
        isSynchronized = checkIfSynchronized();
        if (!isSynchronized) {
            EventWaitInstance received = registerWaitEvents(false, true);
            if (received!=null)
                resume(getExternalEventInstanceDetails(received.getMessageDocumentId()), received.getCompletionCode());
        }
    }
13020
def on_created(self, event):
        ''''''
        if self.trigger != "create":
            return
        action_input = ActionInput(event, "", self.name)
        flows.Global.MESSAGE_DISPATCHER.send_message(action_input)
101151
public void sendEvent(final Map<String, String> params) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                // put user id
                params.put("cid", userId);
                Multimap queryParams = HashMultimap.create();
                for (Map.Entry<String, String> entry : params.entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    Preconditions.checkNotNull(key, "Custom search param key must not be null.");
                    Preconditions.checkNotNull(value, "Custom search param value must not be null.");
                    queryParams.put(key, value);
                }
                viSearchHttpClient.get(ENDPOINT_SEND_ACTIONS, queryParams);
            }
        });
    }
1158883
protected synchronized void sendUpdates() {
        log.debug("sendUpdates");
        // get the current version
        final int currentVersion = getVersion();
        log.debug("Current version: {}", currentVersion);
        // get the name
        final String name = getName();
        //get owner events
        Set<ISharedObjectEvent> ownerEvents = ownerMessage.getEvents();
        if (!ownerEvents.isEmpty()) {
            // get all current owner events - single ordered set going to the event owner
            final TreeSet<ISharedObjectEvent> events = new TreeSet<>(ownerEvents);
            ownerEvents.removeAll(events);
            // send update to "owner" of this update request
            if (source != null) {
                final RTMPConnection con = (RTMPConnection) source;
                // create a worker
                SharedObjectService.submitTask(() -> {
                    Red5.setConnectionLocal(con);
                    con.sendSharedObjectMessage(name, currentVersion, persistent, events);
                    Red5.setConnectionLocal(null);
                });
            }
        } else if (log.isTraceEnabled()) {
            log.trace("No owner events to send");
        }
        // tell all the listeners
        if (!syncEvents.isEmpty()) {
            // get all current sync events 
            final TreeSet<ISharedObjectEvent> events = new TreeSet<>(syncEvents);
            syncEvents.removeAll(events);
            // get the listeners
            Set<IEventListener> listeners = getListeners();
            if (log.isDebugEnabled()) {
                log.debug("Listeners: {}", listeners);
            }
            // updates all registered clients of this shared object
            listeners.stream().filter(listener -> listener != source).forEach(listener -> {
                final RTMPConnection con = (RTMPConnection) listener;
                if (con.isConnected()) {
                    // create a worker
                    SharedObjectService.submitTask(() -> {
                        Red5.setConnectionLocal(con);
                        con.sendSharedObjectMessage(name, currentVersion, persistent, events);
                        Red5.setConnectionLocal(null);
                    });
                } else {
                    log.debug("Skipping {} connection: {}", RTMP.states[con.getStateCode()], con.getId());
                    // if the connection is 'disconnected' remove it
                    if (con.isDisconnected()) {
                        unregister(con);
                    }
                }
            });
        } else if (log.isTraceEnabled()) {
            log.trace("No sync events to send");
        }
    }