handle event via request.
772233
public function handle(EventListenerInterface $listener)
    {
        if (!$listener->getListeners()) {
            return;
        }

        $content = $this->request->getContent();

        try {
            $options = Serializer::parse($content);
        } catch (\InvalidArgumentException $e) {
            $options = [];
        }

        foreach ($listener->getListeners() as $namespace => $callable) {
            $event = new $namespace($options);
            if ($event->isValid()) {
                $listener->trigger($namespace, $event);
                break;
            }
        }
    }
673406
def trigger(self, event, *args):
        """"""
        for handler in self._event_handlers[event]:
            handler(*args)
208731
def handleNotification(self, req):
        """"""
        name = req["method"]
        params = req["params"]
        try: #to get a callable obj 
            obj = getMethodByName(self.service, name)
            rslt = obj(*params)
        except:
            pass
1155363
def listen(cls, event, func):
        """"""
        signal(event).connect(func, sender=cls)
834960
def handler(self, event):
        """"""

        if self.escape(event):  # A chance to escape
            self.stop()
        elif self.diagnostic:
            self._diagnostic(event)
        else:
            self._tap(event)
        #This is needed according to the pyHook tutorials 'http://sourceforge.net/apps/mediawiki/pyhook/index.php?title=PyHook_Tutorial'
        return True
1209662
def respond_for(self, view_function, args, kwargs):
        """"""

        request = args[0]
        form = self.get_requested_form(request)
        if form.is_valid():
            result = self.handle_form_valid(request, form)
            if result:
                return result

        self.update_request(request, form)
        return view_function(*args, **kwargs)
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
11481
def handle(self):
        """"""
        self.close_connection = 1

        self.handle_one_request()
        while not self.close_connection:
            self.handle_one_request()
648515
def _handle_event(self, sid, namespace, id, data):
        """"""
        namespace = namespace or '/'
        self.logger.info('received event "%s" from %s [%s]', data[0], sid,
                         namespace)
        if self.async_handlers:
            self.start_background_task(self._handle_event_internal, self, sid,
                                       data, namespace, id)
        else:
            self._handle_event_internal(self, sid, data, namespace, id)
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)
700157
def on_any_event(self, event):
        """"""
        if os.path.isfile(event.src_path):
            self.callback(event.src_path, **self.kwargs)
1291975
def trigger_event(event=None, **kwargs):
    '''
    
    '''

    res = {'result': False, 'message': 'Something went wrong'}

    data = {}
    for value in ('value1', 'value2', 'value3',
                  'Value1', 'Value2', 'Value3'):
        if value in kwargs:
            data[value.lower()] = kwargs[value]
    data['occurredat'] = time.strftime("%B %d, %Y %I:%M%p", time.localtime())
    result = _query(event=event,
                    method='POST',
                    data=salt.utils.json.dumps(data)
                    )
    if 'status' in result:
        if result['status'] == 200:
            res['result'] = True
            res['message'] = result['text']
        else:
            if 'error' in result:
                res['message'] = result['error']
    return res
237304
def handle_request(self):
        """"""
        try:
            request, client_address = self.get_request()
        except socket.error:
            return

        if self.verify_request(request, client_address):
            self.workerpool.run(self.process_request_thread,
                                **{'request': request,
                                   'client_address': client_address})
428147
def process(self):
        """"""
        try:
            self.receiver(self)
        # TODO RESTException
        except Exception as e:
            current_app.logger.exception('Could not process event.')
            self.response_code = 500
            self.response = dict(status=500, message=str(e))
        return self
1004060
def handleRequest(self, req):
        """"""
        name = req["method"]
        params = req["params"]
        id=req["id"]
        obj=None
        try: #to get a callable obj 
            obj = getMethodByName(self.service, name)
        except MethodNameNotAllowed,e:
            self.sendResponse(id, None, e)
        except:
            self.sendResponse(id, None, MethodNotFound())
        if obj:
            try: #to call the object with parameters
                rslt = obj(*params)
                self.sendResponse(id, rslt, None)
            except TypeError: # wrong arguments
                #todo what if the TypeError was not thrown directly by the callable obj
                s=getTracebackStr()
                self.sendResponse(id, None, InvalidMethodParameters())
            except: #error inside the callable object
                s=getTracebackStr()
                self.sendResponse(id, None, s)
392658
function (event, query, handler, context) {
        return on(this, event, query, handler, context, true);
    }
75628
def __handle_request(self, request, *args, **kw):
        

        self._authenticate(request)
        self._check_permission(request)
        method = self._get_method(request)
        data = self._get_input_data(request)
        data = self._clean_input_data(data, request)
        response = self._exec_method(method, request, data, *args, **kw)
        return self._process_response(response, request)