function to store a event pending to send
776299
function (event) {

	// if event is not from socket, no need to queue
	// TODO: remove connection-specific code from here
	if (event.conn.type !== 'socket')
		return true;

	var socket = event.conn.connector;

	// if no mechanism to store (such as from a bot), just ignore
	// TODO: this is not clean
	if (typeof socket.queuedEvents === 'undefined')
		socket.queuedEvents = {};

	var queue_size = Object.keys(socket.queuedEvents).length;
	if (queue_size > l_queuedEventsPerSocket) {

		LOG.warn('queued event size: ' + queue_size + ' limit exceeded (' + l_queuedEventsPerSocket + ')', l_name);

		// DEBUG purpose (print out events queued)
		for (var i in socket.queuedEvents)
			LOG.sys('queuedEvents[' + i + '] =' + UTIL.stringify(socket.queuedEvents[i].data), l_name);

		return false;
	}

	// store event with the ID to socket's eventlist
	socket.queuedEvents[event.id] = event;

	return true;
}
649922
function emitEvent(emitter, event, data) {    
  process.nextTick(function() {
    emitter.emit(event, data);
  });
}
1149835
function _sendEvent(client, room, event, callback) {
    // Add an extra Promise.resolve() to turn synchronous exceptions into promise rejections,
    // so that we can handle synchronous and asynchronous exceptions with the
    // same code path.
    return Promise.resolve().then(function() {
        const encryptionPromise = _encryptEventIfNeeded(client, event, room);

        if (!encryptionPromise) {
            return null;
        }

        _updatePendingEventStatus(room, event, EventStatus.ENCRYPTING);
        return encryptionPromise.then(() => {
            _updatePendingEventStatus(room, event, EventStatus.SENDING);
        });
    }).then(function() {
        let promise;
        // this event may be queued
        if (client.scheduler) {
            // if this returns a promsie then the scheduler has control now and will
            // resolve/reject when it is done. Internally, the scheduler will invoke
            // processFn which is set to this._sendEventHttpRequest so the same code
            // path is executed regardless.
            promise = client.scheduler.queueEvent(event);
            if (promise && client.scheduler.getQueueForEvent(event).length > 1) {
                // event is processed FIFO so if the length is 2 or more we know
                // this event is stuck behind an earlier event.
                _updatePendingEventStatus(room, event, EventStatus.QUEUED);
            }
        }

        if (!promise) {
            promise = _sendEventHttpRequest(client, event);
        }
        return promise;
    }).then(function(res) {  // the request was sent OK
        if (room) {
            room.updatePendingEvent(event, EventStatus.SENT, res.event_id);
        }
        if (callback) {
            callback(null, res);
        }
        return res;
    }, function(err) {
        // the request failed to send.
        console.error("Error sending event", err.stack || err);

        try {
            // set the error on the event before we update the status:
            // updating the status emits the event, so the state should be
            // consistent at that point.
            event.error = err;
            _updatePendingEventStatus(room, event, EventStatus.NOT_SENT);
            // also put the event object on the error: the caller will need this
            // to resend or cancel the event
            err.event = event;

            if (callback) {
                callback(err);
            }
        } catch (err2) {
            console.error("Exception in error handler!", err2.stack || err);
        }
        throw err;
    });
}
303268
@Override
  public void send(T value, Result<Void> result)
  {
    /*
    if (! init() && pendingSend(value, result)) {
      return;
    }
    */
    
    send(value);

    result.ok(null);
  }
118377
function() {
      var t = this,
          now = Date.now();

      // This kicks off the send
      t.lastSendTime = now;
      t.set({
        bundle: t.queue,
        sequence: t.get('sequence') + 1
      });

      // Reset
      t.queue = [];
      if (t.timer) {
        clearTimeout(t.timer);
        t.timer = null;
      }
    }
614755
function onevent(event) {
        // Event should have the following properties:
        // * `id: string`: an event identifier.
        // * `type: string`: an event type.
        // * `data: any`: an event data.
        // * `reply: boolean`: true if this event requires the reply.

        // If the client sends a plain event, dispatch it.
        if (!event.reply) {
          self.emit(event.type, event.data);
        } else {
          var latch;
          // A function to create a function.
          function reply(success) {
            // A controller function.
            return function(value) {
              // This latch prevents double reply.
              if (!latch) {
                latch = true;
                self.send("reply", {id: event.id, data: value, exception: !success});
              }
            };
          }

          // Here, the controller is passed to the event handler as 2nd argument and allows
          // to call the server's `resolved` or `rejected` callback by sending `reply` event.
          self.emit(event.type, event.data, {resolve: reply(true), reject: reply(false)});
        }
      }
1318818
def send_wait(self,text):
	""""""
	self.send(text)
	time.sleep(len(text)*PiLite.COLS_PER_CHAR*self.speed/1000.0)
1202958
def _flush_events(self):
        """"""
        if self._sink is not None:
            for event in self._pending_events:
                self._sink.receive(event)
        self._pending_events = []
824323
function (event) {

	// check if connection object exists
	if (typeof event.conn === 'undefined') {
		LOG.error('no connection records, cannot respond to request', l_name);
		return false;
	}

	// if no mechanism to store (such as from a bot), just ignore
	// TODO: cleaner approach?
	if (event.conn.type !== 'socket' ||
    	event.conn.connector.queuedEvents === undefined) {
		return true;
	}

	var socket = event.conn.connector;

	// check if id exist
	if (socket.queuedEvents.hasOwnProperty(event.id) === false) {
		LOG.error('event not found. id = ' + event.id, l_name);
		LOG.stack();
		return false;
	}

	// remove current event from the socket's event queues
	delete socket.queuedEvents[event.id];

	return true;
}
441623
async def send_event(self, client_id, service_name, event_name, event_info, directed_client=None):
        """"""

        if directed_client is not None and directed_client != client_id:
            return

        client_info = self.clients.get(client_id)
        if client_info is None:
            self._logger.warning("Attempted to send event to invalid client id: %s", client_id)
            return

        conn = client_info['connection']

        event = dict(service=service_name)
        if event_info is not None:
            event['payload'] = event_info

        self._logger.debug("Sending event: %s", event)

        await self.server.send_event(conn, event_name, event)
223283
function forwardEvent (event) {
    var n = Atok.events[event]
      , args = []

    while (n > 0) args.push('a' + n--)
    args = args.join()

    return 'atok.on("'
      + event
      + '", function forwardEvent (' + args + ') { self.emit_' + event + '(' + args + ') })'
  }
342469
public void sendEvent(Event event) {
        for (ShouldSendEventCallback shouldSendEventCallback : shouldSendEventCallbacks) {
            if (!shouldSendEventCallback.shouldSend(event)) {
                logger.trace("Not sending Event because of ShouldSendEventCallback: {}", shouldSendEventCallback);
                return;
            }
        }

        try {
            connection.send(event);
        } catch (LockedDownException | TooManyRequestsException e) {
            logger.debug("Dropping an Event due to lockdown: " + event);
        } catch (Exception e) {
            logger.error("An exception occurred while sending the event to Sentry.", e);
        } finally {
            getContext().setLastEventId(event.getId());
        }
    }
526440
function _onLoadEventFired(event, res) {
        // res = {timestamp}
        Inspector.DOM.getDocument(function onGetDocument(res) {
            exports.trigger("getDocument", res);
            // res = {root}
            _idToNode = {};
            _pendingRequests = 0;
            exports.root = new DOMNode(exports, res.root);
        });
    }
739285
def send(self, event):
        
        try:
            processed_event = self.process_event(event)
        except EventEmissionExit:
            return
        else:
            self.send_to_backends(processed_event)
547134
def wait(self, timeout=None):
        
        import threading

        if self._state!=self.PENDING:
            return

        e = threading.Event()
        self.addCallback(lambda v: e.set())
        self.addErrback(lambda r: e.set())
        e.wait(timeout)
11206
function ontick(next) {
      // No point in waiting that long
      if (next >= timeoutOn) {
        timeout();
        return;
      }

      const activeWindow = eventLoop.active;
      if (completionFunction && activeWindow.document.documentElement)
        try {
          const waitFor   = Math.max(next - Date.now(), 0);
          // Event processed, are we ready to complete?
          const completed = completionFunction(activeWindow, waitFor);
          if (completed)
            done();
        } catch (error) {
          done(error);
        }

    }
655310
def event_confirmation(self, date, time, pid, commerce_id, transaction_id, request_ip, order_id):
        '''
        '''
        raise NotImplementedError("Logging Handler must implement event_confirmation")