Broadcast the given event.

@param  array  $channels
@param  string $event
@param  array  $payload
@return void
174018
public function broadcast(array $channels, $event, array $payload = [])
    {
        $this->pushman->push($event, $channels, $payload);
    }
827668
public function push($payload): void
    {
        // attach sender if not broadcast
        if (! $this->broadcast && $this->sender && ! $this->hasDescriptor($this->sender)) {
            $this->addDescriptor($this->sender);
        }

        // check if to broadcast to other clients
        if ($this->shouldBroadcast()) {
            $this->addDescriptors($this->getWebsocketConnections());
        }

        // push message to designated fds
        foreach ($this->descriptors as $descriptor) {
            if ($this->shouldPushToDescriptor($descriptor)) {
                $this->server->push($descriptor, $payload, $this->opcode);
            }
        }
    }
980018
public function dispatch($event, $payload = array(), $halt = false)
    {
        $responses = array();

        // When the given "event" is actually an object we will assume it is an event
        // object and use the class as the event name and this event itself as the
        // payload to the handler, which makes object based events quite simple.
        if (is_object($event)) {
            list($payload, $event) = array(array($event), get_class($event));
        }

        // If an array is not given to us as the payload, we will turn it into one so
        // we can easily use call_user_func_array on the listeners, passing in the
        // payload to each of them so that they receive each of these arguments.
        else if (! is_array($payload)) {
            $payload = array($payload);
        }

        $this->dispatching[] = $event;

        if (isset($payload[0]) && ($payload[0] instanceof ShouldBroadcastInterface)) {
            $this->broadcastEvent($payload[0]);
        }

        foreach ($this->getListeners($event) as $listener) {
            $response = call_user_func_array($listener, $payload);

            // If a response is returned from the listener and event halting is enabled
            // we will just return this response, and not call the rest of the event
            // listeners. Otherwise we will add the response on the response list.
            if (! is_null($response) && $halt) {
                array_pop($this->dispatching);

                return $response;
            }

            // If a boolean false is returned from a listener, we will stop propagating
            // the event to any further listeners down in the chain, else we keep on
            // looping through the listeners and dispatching every one in our sequence.
            if ($response === false) {
                break;
            }

            $responses[] = $response;
        }

        array_pop($this->dispatching);

        if (! $halt) {
            return $responses;
        }
    }
874373
public function subscribe( $channels, Closure $callback, $connection = null, $method = 'subscribe' )
	{
		$loop = $this->connection( $connection )->pubSubLoop();

		call_user_func_array( [$loop, $method], (array) $channels );

		foreach ( $loop as $message )
		{
			if ( $message->kind === 'message' || $message->kind === 'pmessage' )
			{
				call_user_func( $callback, $message->payload, $message->channel );
			}
		}

		unset( $loop );
	}
1051601
public function listen($event, $handler)
    {
        if(array_key_exists($event, $this->broadcast)) {

            $eventObject = $this->getEventObject($event, $this->broadcast[$event]);

            if(is_callable($handler)) {
                call_user_func_array($handler, [$eventObject]);
            } else {
                call_user_func_array([$this->app->make($handler), 'listen'], [$eventObject]);
            }
        }
    }
600934
@Handler
    public void onOutput(Output<ByteBuffer> event, Channel channel) {
        Writer writer = outputWriters.get(channel);
        if (writer != null) {
            writer.write(event.buffer());
        }
    }
638236
public function handle($event, $payload)
    {
        list($model) = $payload;
        
        // Check for matching input elements
        foreach (Request::input() as $key => $val) {
            if (preg_match('#^'.self::PREFIX.'(.+)#', $key, $matches)) {
                $this->updateRelationship($model, $matches[1]);
            }
        }
    }
1306809
public function publishBatch($channel, array $messages)
    {
        foreach ($messages as $message) {
            $this->publish($channel, $message);
        }
    }
1064232
public function emit($event, ...$parameters)
    {
        $event = $this->ensureEvent($event);
        $event->setEmitter($this);
        $event->setContexts($parameters);

        $listeners = $this->getListeners($event);

        foreach ($listeners as $listener) {
            $listener->handle($event);
        }

        unset($listeners, $event);
    }
853897
public function fire($event, $payload = [], $halt = false)
    {

        if ($this->filter && !call_user_func($this->filter, $event, $payload)) {
            return null;
        }

        if (!is_array($payload)) {
            $payload = [$payload];
        }

        $returnValues = [];

        foreach ($this->collectListeners($event, $payload) as $listener) {
            $returnValue = $this->callListener($listener, $event, $payload);

            if ($returnValue !== null && $halt) {
                return $returnValue;
            }

            if ($returnValue === false) {
                $returnValues[] = false;
                return $returnValues;
            }

            $returnValues[] = $returnValue;
        }

        return $returnValues;
    }
772872
public function fire($event, &$payload = [], $halt = false)
    {
        // When the given "event" is actually an object we will assume it is an event
        // object and use the class as the event name and this event itself as the
        // payload to the handler, which makes object based events quite simple.
        if ( is_object($event) )
        {
            list($payload, $event, $eventName) = [ [$event], $event, get_class($event) ];
        }
        else
        {
            $eventName = $event;
        }

        $responses = [];

        // If an array is not given to us as the payload, we will turn it into one so
        // we can easily use call_user_func_array on the listeners, passing in the
        // payload to each of them so that they receive each of these arguments.
        if ( ! is_array($payload) )
        {
            $payload = [$payload];
        }

        $this->firing[] = $eventName;

        if ( isset($payload[0]) && $payload[0] instanceof ShouldBroadcast )
        {
            $this->broadcastEvent($payload[0]);
        }

        foreach ($this->getListeners($event) as $listener)
        {
            dd($listener());
        	
        	try
        	{
        		$response = call_user_func_array($listener, $payload);
        	}
            catch(ValidationException $e)
            {
            	$this->validationExceptions[] = $e;
            	$response = 0;
            }

            // If a response is returned from the listener and event halting is enabled
            // we will just return this response, and not call the rest of the event
            // listeners. Otherwise we will add the response on the response list.
            if (!is_null($response) && $halt)
            {
                array_pop($this->firing);

                return $response;
            }

            // If a boolean false is returned from a listener, we will stop propagating
            // the event to any further listeners down in the chain, else we keep on
            // looping through the listeners and firing every one in our sequence.
            if ($response === false)
            {
                break;
            }

            $responses[] = $response;
        }

        array_pop($this->firing);

        if( ! empty($this->validationExceptions) )
        {
        	throw new ValidationException([], 422, $this->validationExceptions);
        	
        }

        return $halt ? null : $responses;
    }
949355
@SuppressWarnings("PMD.UseVarargs")
    public void fire(Event<?> event, Channel[] channels) {
        eventPipeline.add(event, channels);
    }
972996
public function dispatch($event, $payload = [], $halt = false)
    {
        $this->firing[] = $event;

        foreach ($this->getListeners($event) as $listener) {
            $payload = call_user_func_array($listener, (array) $payload);
        }

        array_pop($this->firing);

        return $payload;
    }
979270
protected function fireEvent($event, $payload = [ ], $halt = false)
    {
        if (! isset($this->dispatcher)) {
            $this->initEventDispatcher();
        }

        $dispatcher = $this->dispatcher;
        $status     = $this->dispatcherStatus;
        if (! $dispatcher || $status === false) {
            return;
        }
        $method = $halt ? 'until' : 'fire';

        return $dispatcher->{$method}($event, $payload);
    }
1263383
public function push($event, $payload = [])
    {
        $this->listen($event.'_pushed', function () use ($event, $payload) {
            $this->dispatch($event, $payload);
        });
    }
945465
def emit(event, data = {}, channel = nil)
      message = { event: event, data: MultiJson.dump(data) }
      message[:channel] = channel if channel

      PusherFake.log("SEND #{id}: #{message}")

      socket.send(MultiJson.dump(message))
    end
1262898
public function notify($event, $payload)
    {
        $result = null;

        foreach ($this->handlers as $condition => $handlers) {
            if ('*' === $condition || ($condition & $event) === $event) {
                foreach ($handlers as $handler) {
                    if ($clause = $this->clauses[spl_object_hash((object) $handler)] ?? null) {
                        if ($clause->intercepted($payload)) {
                            continue;
                        }
                    }
                    $response = $this->callHandler($handler, $payload);

                    switch (true) {
                        case $response instanceof TerminateResult:
                            return $response->content;
                        case true === $response:
                            continue 2;
                        case false === $response:
                            break 2;
                        case !empty($response) && !($result instanceof FinallyResult):
                            $result = $response;
                    }
                }
            }
        }

        return $result instanceof FinallyResult ? $result->content : $result;
    }