Responds to an event.

@param string $event The name of the event ("action.event")
@param array $data The data for this event (optional)
@throws \InvalidArgumentException if the event name is invalid.
542606
public function respond($event, array $data = [])
    {
        $event = (string) $event;

        if (strpos($event, '.') == false) {
            throw new \InvalidArgumentException('The event name is invalid (expecting "action.event")');
        }

        foreach ($this->listeners as $pattern => $listener) {
            if (self::match($pattern, $event)) {
                call_user_func($listener, $data, $event);
            }
        }
    }
645376
public function onCommandBeforePrepare(Event $event) {
        /** @var Command $command */
        $command = $event['command'];
        if (in_array($command->getName(), $this->commands)) {
            // Get the interesting parameters
            $source = $command->get($this->sourceParameter);
            $body = $command->get($this->bodyParameter);

            // If a file path is passed in then get the file handle
            if (is_string($source) && file_exists($source)) {
                $body = fopen($source, 'rb');
            }

            // Prepare the body parameter and remove the source file parameter
            if (null !== $body) {
                $command->remove($this->sourceParameter);
                $command->set($this->bodyParameter, EntityBody::factory($body));
            } else {
                throw new InvalidArgumentException(
                        "You must specify a non-null value for the {$this->bodyParameter} or {$this->sourceParameter} parameters.");
            }
        }
    }
1009018
function onEvent($event)
    {
        if (!isset($event->data[0]['id'])) {
            throw new ClientError('Invalid event data, payment id not found.');
        }

        call_user_func($this->callback, $this->service->get($event->data[0]['id']));
    }
721886
private function assertEventName($name)
    {
        if (!in_array($name, $this->getEventNames())) {
            throw new \InvalidArgumentException(sprintf(
                'The supplied event name: %s is not one of the expected: %s',
                $name,
                implode(', ', $this->getEventNames())
            ));
        }
    }
655804
public function call(string $event, $data = null)
    {
        if (!$this->eventExists($event)) {
            return;
        }

        // inject request param on connect event
        $isConnect = $event === static::EVENT_CONNECT;
        $dataKey   = $isConnect ? 'request' : 'data';

        return $this->app->invoke($this->callbacks[$event], [
            'websocket' => $this,
            $dataKey    => $data,
        ]);
    }
739019
public function handle($eventName, $data = null)
    {
        $results = [];

        if ($actions = $this->getEventActions($eventName)) {

            $actions = is_array($actions) ? $actions : [$actions];
            $data = is_array($data) ? $data : [$data];

            foreach ($actions as $action) {
                if ($result = $this->call($eventName, $action, $data)) {
                    $results[$action] = $result;
                }
            }
        }

        return count($results) === 1 ? reset($results) : $results;
    }
938185
public function broadcast($event, $data)
    {
        if(!array_key_exists($event, $this->events)) {
            throw new EventNotFoundException("Event [ {$event} ] does not exists.");
        }

        $this->broadcast[$event] = $data;
    }
1348037
public function trigger($name, Event $event = null)
    {
        if (! isset($event)) {
            $event = new Event($this->subject);
        }
        if (isset($this->parent)) {
            if (! $this->parent->trigger($this->subjectClass . '.' . $name, $event)) {
                return false;
            }
        }
        if (isset($this->events[$name])) {
            $event->name = $name;
            foreach ($this->events[$name] as $function) {
                $continue = call_user_func($function, $event);
                if ($event->stopped or $continue === false) {
                    return false;
                }
            }
        } elseif (strpos($name, '.') === false) {
            throw new InvalidEventException(
                'Event subject "' . $this->subjectClass
                . '" does not have event "' . $name . '"'
            );
        }
        return true;
    }
153202
public function raiseEvent(Event $event)
    {
        $name = $event->getName();
        if (isset($this->handlers[ $name ])) {
            ksort($this->handlers[ $name ]);
            $response = null;
            foreach ($this->handlers[ $name ] as $handlers) {
                foreach ($handlers as $handler) {
                    $response = $handler($event);
                }
            }
            $event->setResponse($response);
            $event->setHandled();
        }

        return $event;
    }
216935
public static function validate($data)
    {
        if (count(array_intersect_key(array_flip(static::$requiredParams), $data)) === count(static::$requiredParams)) {
            return true;
        }

        throw new InvalidArgumentException();
    }
365067
public static function trigger($event, &$data)
    {
        if (!isset(self::$manager)) {
            self::init();
        }

        return self::$manager->triggerEvent($event, $data);
    }
148861
public function on(string $event, $callback)
    {
        if (! is_string($callback) && ! is_callable($callback)) {
            throw new InvalidArgumentException(
                'Invalid websocket callback. Must be a string or callable.'
            );
        }

        $this->callbacks[$event] = $callback;

        return $this;
    }
1143705
public function fire(string $event, array $arguments = null) {
        $arguments = (array)$arguments;
        foreach ($this->getBindings($event) as $callback) {
            if (is_callable($callback)) {
                call_user_func_array($callback, $arguments);
            }
        }
    }
393288
public function checkEvent($event)
    {
        if (!in_array($event, self::$AVAILABLE_EVENTS)) {
            throw new \InvalidArgumentException(sprintf('Unsupported event: `%s`, available events: `%s`',
                    $event,
                    implode(', ', self::$AVAILABLE_EVENTS)
                )
            );
        }
    }
132089
protected function triggerEvent($event, $source = null, $data = null) {
		$this->getEventsManager()->trigger($event, $source, $data);
	}
335001
public function sendData($data)
    {
        $response = $this->gocardless->events()->get($this->getEventId());

        return $this->response = new EventResponse($this, $response);
    }
843902
public function serialize(EventInterface $event)
    {
        if (!$event instanceof \JsonSerializable) {
            throw new \InvalidArgumentException(sprintf('Cannot serialize %s event.', $event->getName()));
        }

        return json_encode($event);
    }