Event specific packet handling logic.

        Break packet into events and fires configured event callback or
        nicely prints events for console.
185833
def _handle_packet(self, packet):
        
        events = packet_events(packet)

        for event in events:
            if self.ignore_event(event['id']):
                log.debug('ignoring event with id: %s', event)
                continue
            log.debug('got event: %s', event)
            if self.event_callback:
                self.event_callback(event)
            else:
                self.handle_event(event)
330551
private void fireMessageEventRequestListeners(
        Jid from,
        String packetID,
        String methodName) {
        try {
            Method method =
                MessageEventRequestListener.class.getDeclaredMethod(
                    methodName,
                    new Class<?>[] { Jid.class, String.class, MessageEventManager.class });
            for (MessageEventRequestListener listener : messageEventRequestListeners) {
                method.invoke(listener, new Object[] { from, packetID, this });
            }
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "Error while invoking MessageEventRequestListener's  " + methodName, e);
        }
    }
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)});
        }
      }
107177
def _handle_events(self, fd: int, events: int) -> None:
        
        action = 0
        if events & ioloop.IOLoop.READ:
            action |= pycurl.CSELECT_IN
        if events & ioloop.IOLoop.WRITE:
            action |= pycurl.CSELECT_OUT
        while True:
            try:
                ret, num_handles = self._multi.socket_action(fd, action)
            except pycurl.error as e:
                ret = e.args[0]
            if ret != pycurl.E_CALL_MULTI_PERFORM:
                break
        self._finish_pending_requests()
533297
function(event, id, msg) {
      var self = this;
      var events = self['_on' + event];

      // Loop through event store and fire all functions.
      for (var i=events.length-1; i>=0; i--) {
        // Only fire the listener if the correct ID is used.
        if (!events[i].id || events[i].id === id || event === 'load') {
          setTimeout(function(fn) {
            fn.call(this, id, msg);
          }.bind(self, events[i].fn), 0);

          // If this event was setup with `once`, remove it.
          if (events[i].once) {
            self.off(event, events[i].fn, events[i].id);
          }
        }
      }

      // Pass the event type into load queue so that it can continue stepping.
      self._loadQueue(event);

      return self;
    }
292066
def process_events(args):
    """"""
    client = EventsClient.from_config()
    client.set_debug(True)
    if args.get:
        response = client.get_events()
    elif args.flush:
        response = client.flush_events()
    return response
1172728
def _handle_ping(self, packet, protocol):
        
        if 'payload' in packet:
            is_valid_node = True
            node_ids = list(packet['payload'].values())
            for node_id in node_ids:
                if self._repository.get_node(node_id) is None:
                    is_valid_node = False
                    break
            if is_valid_node:
                self._pong(packet, protocol)
        else:
            self._pong(packet, protocol)
40278
def packet_in_handler(self, evt):
        """"""
        req_pkt = packet.Packet(evt.msg.data)
        if slow.lacp in req_pkt:
            (req_lacp, ) = req_pkt.get_protocols(slow.lacp)
            (req_eth, ) = req_pkt.get_protocols(ethernet.ethernet)
            self._do_lacp(req_lacp, req_eth.src, evt.msg)
        else:
            self.send_event_to_observers(EventPacketIn(evt.msg))
1151073
def handler(event, context):  # pylint: disable=W0613
    
    records = deserialize_records(event['Records'])

    # Split records into two groups, update and delete.
    # We don't want to query for deleted records.
    update_records, delete_records = group_records_by_type(records, UPDATE_EVENTS)

    LOG.debug('[@] Processing update records...')
    process_update_records(update_records)
    LOG.debug('[@] Completed processing of update records.')

    LOG.debug('[@] Processing delete records...')
    process_delete_records(delete_records)
    LOG.debug('[@] Completed processing of delete records.')

    LOG.debug('[@] Successfully updated current Historical table')
217960
public void processResponseEvent(FireableEventType eventType, ResponseEvent event, XCAPResourceAdaptorActivityHandle handle){
        
    	if (tracer.isFineEnabled()) {    		            		
    		tracer.fine("NEW RESPONSE EVENT");        
    	}
                        
        try {                	
            sleeEndpoint.fireEvent(handle,eventType, event, null, null);
        } catch (Exception e) {           
            tracer.severe("unable to fire event",e);
        }        
    }
1141193
function onPacket(packet) {

		var respond;

		try {
			if (packet.data && typeof packet.data == 'object') {
				packet.data = JSON.undry(packet.data);
			}
		} catch (err) {
			console.log('ERROR UNDRYING PACKET:', err, packet);
			return;
		}

		if (packet.respond) {
			respond = function respond(err, data) {
				var responsePacket = {};

				responsePacket.err = err;
				responsePacket.respond_to = packet.id;
				responsePacket.data = data;

				server.emit('response', responsePacket);
			};
		}

		// See if this is for a specific linkup
		if (packet.link) {
			if (that.linkups[packet.link]) {
				if (packet.stream) {
					that.linkups[packet.link].emit(packet.type, packet.data, packet.stream, respond, null);
				} else {
					that.linkups[packet.link].emit(packet.type, packet.data, respond, null);
				}
			}

			return;
		}

		if (packet.stream) {
			that.emit(packet.type, packet.data, packet.stream, respond, null);
		} else {
			that.emit(packet.type, packet.data, respond, null);
		}
	}
970873
public static void dispatchSCMEvent(int eventID)
    {
        switch(eventID)
        {
          case SERVICE_CONTROL_STOP:
          case SERVICE_CONTROL_PAUSE:
              stopAll();
              break;
              
          case SERVICE_CONTROL_CONTINUE :
              startAll();
              break;
              
          case SERVICE_CONTROL_SHUTDOWN:
              destroyAll();
              break;
              
          case SERVICE_CONTROL_PARAMCHANGE:
              stopAll();
              destroyAll();
              createAll();
              startAll();
              break;

          default:
              break;
        }
    }
1369850
def _handle_stdout_event(self, fd, events):
        """"""

        assert fd == self.fd_stdout

        if events & self.ioloop.READ:
            # got data ready to read
            data = ''

            # Now basically we have two cases: either the client supports
            # HTTP/1.1 in which case we can stream the answer in chunked mode
            # in HTTP/1.0 we need to send a content-length and thus buffer the complete output
            if self.request.supports_http_1_1():
                if not self.headers_sent:
                    self.sent_chunks = True
                    self.headers.update({'Date': get_date_header(), 'Transfer-Encoding': 'chunked'})
                    data = 'HTTP/1.1 200 OK\r\n' + '\r\n'.join([ k + ': ' + v for k, v in self.headers.items()]) + '\r\n\r\n'

                    if self.output_prelude:
                        data += hex(len(self.output_prelude))[2:] + "\r\n" # cut off 0x
                        data += self.output_prelude + "\r\n"

                    self.headers_sent = True

                payload = os.read(fd, 8192)
                if events & self.ioloop.ERROR: # there might be data remaining in the buffer if we got HUP, get it all
                    remainder = True
                    while remainder != '': # until EOF
                        remainder = os.read(fd, 8192)
                        payload += remainder

                data += hex(len(payload))[2:] + "\r\n" # cut off 0x
                data += payload + "\r\n"

            else:
                if not self.headers_sent:
                    # Use the over-eager blocking read that will get everything until we hit EOF
                    # this might actually be somewhat dangerous as noted in the subprocess documentation
                    # and lead to a deadlock. This is only a legacy mode for HTTP/1.0 clients anyway,
                    # so we might want to remove it entirely anyways
                    payload = self.process.stdout.read()
                    self.headers.update({'Date': get_date_header(), 'Content-Length': str(len(payload))})
                    data = 'HTTP/1.0 200 OK\r\n' + '\r\n'.join([ k + ': ' + v for k, v in self.headers.items()]) + '\r\n\r\n'
                    self.headers_sent = True
                    data += self.output_prelude + payload
                else:
                    # this is actually somewhat illegal as it messes with content-length but 
                    # it shouldn't happen anyways, as the read above should have read anything
                    # python docs say this can happen on ttys...
                    logger.error("This should not happen")
                    data = self.process.stdout.read()

            if len(data) == 8200:
                self.number_of_8k_chunks_sent += 1
            else:
                if self.number_of_8k_chunks_sent > 0:
                    logger.debug('Sent %d * 8192 bytes', self.number_of_8k_chunks_sent)
                    self.number_of_8k_chunks_sent = 0

                logger.debug('Sending stdout to client %d bytes: %r', len(data), data[:20])
            self.request.write(data)

        # now we can also have an error. This is because tornado maps HUP onto error
        # therefore, no elif here!
        if events & self.ioloop.ERROR:
            logger.debug('Error on stdout')
            # ensure file is closed
            if not self.process.stdout.closed:
                self.process.stdout.close()
            # remove handler
            self.ioloop.remove_handler(self.fd_stdout)
            # if all fds are closed, we can finish
            return self._graceful_finish()
472083
def packet_in_handler(self, evt):
        """"""
        msg = evt.msg
        dpid = msg.datapath.id

        req_pkt = packet.Packet(msg.data)
        req_igmp = req_pkt.get_protocol(igmp.igmp)
        if req_igmp:
            if self._querier.dpid == dpid:
                self._querier.packet_in_handler(req_igmp, msg)
            else:
                self._snooper.packet_in_handler(req_pkt, req_igmp, msg)
        else:
            self.send_event_to_observers(EventPacketIn(msg))
766115
def exec_event_handler(self, event, transactional=False):
        """"""
        # QUESTION: Should we raise an exception if `event` is not in some
        # known event-type list?

        callbacks = self._options.get('callbacks', {})

        handler = callbacks.get(event)

        if not handler:
            raise Exception('Handler not defined!!!')

        handler.start(transactional=transactional)
1333860
def handle_event(self, package):
        '''
        
        '''
        if not self.ready:
            raise tornado.gen.Return()
        tag, data = salt.utils.event.SaltEvent.unpack(package)
        log.debug(
            'Minion of \'%s\' is handling event tag \'%s\'',
            self.opts['master'], tag
        )
        tag_functions = {
                         'beacons_refresh': self._handle_tag_beacons_refresh,
                         'environ_setenv': self._handle_tag_environ_setenv,
                         'fire_master': self._handle_tag_fire_master,
                         'grains_refresh': self._handle_tag_grains_refresh,
                         'matchers_refresh': self._handle_tag_matchers_refresh,
                         'manage_schedule': self._handle_tag_manage_schedule,
                         'manage_beacons': self._handle_tag_manage_beacons,
                         '_minion_mine': self._handle_tag_minion_mine,
                         'module_refresh': self._handle_tag_module_refresh,
                         'pillar_refresh': self._handle_tag_pillar_refresh,
                         'salt/auth/creds': self._handle_tag_salt_auth_creds,
                         '_salt_error': self._handle_tag_salt_error,
                         '__schedule_return': self._handle_tag_schedule_return,
                         master_event(type='disconnected'): self._handle_tag_master_disconnected_failback,
                         master_event(type='failback'): self._handle_tag_master_disconnected_failback,
                         master_event(type='connected'): self._handle_tag_master_connected,
                         }

        # Run the appropriate function
        for tag_function in tag_functions:
            if tag.startswith(tag_function):
                tag_functions[tag_function](tag, data)
763627
@Override
	public void process(Packet message, MessageContext ctx)
	{
		if (MalisisGui.current() != null)
			MalisisGui.current().close();
	}