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;
    }
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;
    }
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 ; }
Emit data and reset some status.

@param string
@param mixed

@return boolean
Emit data and reset some status .