Raise a given event with the supplied data.

@param  string $event Name of event to be raised
@param  mixed  $data  Data that should be passed to each callback (optional)
@return true
358250
public static function fire($event, $data = null)
    {
        if (!is_array($data)) {
            $data = array($data);
        }
        array_unshift($data, $event);

        $retval = true;

        foreach (array('*', $event) as $e) {
            if (!array_key_exists($e, self::$events)) {
                continue;
            }

            foreach (self::$events[$e] as $callback) {
                if (!is_callable($callback)) {
                    continue;
                }

                if (($retval = call_user_func_array($callback, $data)) === false) {
                    break 2;
                }
            }
        }

        return $retval !== false;
    }
931120
public function notify($event, array $data = [])
    {
        $event = (string) $event;

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

        $action = substr($event, 0, $pos);

        if (!isset($this->responders[$action])) {
            return;
        }

        if (isset($this->data[$action])) {
            $data = array_merge($this->data[$action], $data);
        }

        foreach ($this->responders[$action] as $responder) {
            if ($responder instanceof ResponderInterface) {
                $responder->respond($event, $data);
            } elseif (is_callable($responder)) {
                $responder($event, $data);
            }
        }
    }
166001
public function publish(Event $event)
    {
        // absence of a handlers is not a error
        foreach ($this->handlers as $handler) {
            call_user_func($handler, $event);
        }

        return true;
    }
674261
public function call(string $event, $data = null)
    {
        if (! $this->eventExists($event)) {
            return null;
        }

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

        // dispatch request to pipeline if middleware are set
        if ($isConnect && count($this->middleware)) {
            $data = $this->setRequestThroughMiddleware($data);
        }

        return App::call($this->callbacks[$event], [
            'websocket' => $this,
            $dataKey => $data,
        ]);
    }
1104629
private static function onReceivedMessage(string $event, $data)
    {
        foreach (self::$onMessage[$event] ?? [] as $callback) {
            asyncCall($callback, $data);
        }
    }
898040
public function dispatch(string $name, $data = [])
    {
        if (!isset($this->events[$name])) {
            throw new \Exception("Event '$name' not found in ".__CLASS__.' in stack!');
        }

        foreach ($this->events[$name] as $callback) {
            switch ($callback) {
                case is_object($callback) && ($callback instanceof Closure):
                    return $callback($name, $data);
                    break;
                case string_has($callback, '@'):
                    return $this->callFunction($callback, $data);
                    break;
                case string_has($callback, '::'):
                    return $this->callUserFunctionEvent($callback);
                    break;
                case is_string($callback) && !string_has($callback, '@'):
                    call_user_func($callback, $data);
                    break;
            }
        }
    }
1015274
protected function create(Event $event)
    {
        $this->dispatch(static::EVENT_CREATE_BEFORE, $event);
        if (!$event->isPropagationStopped()) {
            $this->createProcess($event);
            if (!$event->isPropagationStopped()) {
                $this->dispatch(static::EVENT_CREATE_AFTER, $event);
            }
        }
    }
357773
public function beforeMarshal(Event $event, ArrayAccess $data) {
		if (!$this->_isFileUploadPresent($data)) {
			return;
		}

		$this->_getFileInfoFromUpload($data);
	}
913138
public function hasListener($event): bool
    {
        $name = $this->getEventName($event);

        if (isset($this->listeners[$name])) {
            foreach ($this->listeners[$name] as $listeners) {
                if (count($listeners) > 0) {
                    return true;
                }
            }
        }

        unset($name);

        return false;
    }
548931
public static function event($event, $callback, $override = false)
    {
        $class = get_called_class();
        if ($override) {
            self::$event[$class][$event] = [];
        }
        self::$event[$class][$event][] = $callback;
    }
528932
private function setData($data) {

		if(false === is_array($data)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
   		}

		$this -> data = $data;
	}
1345488
public function emit(string $event, $data): bool
    {
        $fds      = $this->getFds();
        $assigned = !empty($this->to);

        // if no fds are found, but rooms are assigned
        // that means trying to emit to a non-existing room
        // skip it directly instead of pushing to a task queue
        if (empty($fds) && $assigned) {
            return false;
        }

        $result = $this->app->make(Server::class)->task([
            'action' => static::PUSH_ACTION,
            'data'   => [
                'sender'    => $this->sender,
                'fds'       => $fds,
                'broadcast' => $this->isBroadcast,
                'assigned'  => $assigned,
                'event'     => $event,
                'message'   => $data,
            ],
        ]);

        $this->reset();

        return $result !== false;
    }
365067
public static function trigger($event, &$data)
    {
        if (!isset(self::$manager)) {
            self::init();
        }

        return self::$manager->triggerEvent($event, $data);
    }
965550
protected function trigger($event, ...$arguments)
    {
        if (!empty($this->handlers[$event])) {
            /** @var callable $handler */
            foreach ($this->handlers[$event] as $handler) {
                call_user_func_array($handler, $arguments);
            }
        }
    }
1101721
protected function getEventObject($event, $data)
    {
        $eventClass = new ReflectionClass($this->getEventClass($event));

        return $eventClass->newInstanceArgs($data);
    }
130207
public function setData($data)
    {
        foreach($this->data as $args)
        {
            Event::off(...$args);
        }
        $this->data = $data;
        foreach($this->data as $args)
        {
            Event::on(...$args);
        }
    }
860879
protected function update(Data $data)
    {
        $this->__before('update', $data);
        $data->validate();

        if (!$this->doUpdate($data)) {
            return false;
        }

        $this->pack([], $data);
        $this->__after('update', $data);

        return true;
    }