src/Worker.php
private function handleControl(string $body = null, &$header = null, int $flags = 0): bool
    {
        $header = $body;
        if (is_null($body) || $flags & Relay::PAYLOAD_RAW) {
            // empty or raw prefix
            return true;
        }

        $p = json_decode($body, true);
        if ($p === false) {
            throw new RoadRunnerException("invalid task context, JSON payload is expected");
        }

        // PID negotiation (socket connections only)
        if (!empty($p['pid'])) {
            $this->relay->send(
                sprintf('{"pid":%s}', getmypid()), Relay::PAYLOAD_CONTROL
            );
        }

        // termination request
        if (!empty($p['stop'])) {
            return false;
        }

        // parsed header
        $header = $p;

        return true;
    }
private function handleControl(string $body = null, &$header = null, int $flags = 0): bool
    {
        $header = $body;
        if (is_null($body) || $flags & Relay::PAYLOAD_RAW) {
            // empty or raw prefix
            return true;
        }

        $p = json_decode($body, true);
        if ($p === false) {
            throw new RoadRunnerException("invalid task context, JSON payload is expected");
        }

        // PID negotiation (socket connections only)
        if (!empty($p['pid'])) {
            $this->relay->send(
                sprintf('{"pid":%s}', getmypid()), Relay::PAYLOAD_CONTROL
            );
        }

        // termination request
        if (!empty($p['stop'])) {
            return false;
        }

        // parsed header
        $header = $p;

        return true;
    }
private function handleControl ( string $ body = null , & $ header = null , int $ flags = 0 ) : bool { $ header = $ body ; if ( is_null ( $ body ) || $ flags & Relay :: PAYLOAD_RAW ) { // empty or raw prefix return true ; } $ p = json_decode ( $ body , true ) ; if ( $ p === false ) { throw new RoadRunnerException ( "invalid task context, JSON payload is expected" ) ; } // PID negotiation (socket connections only) if ( ! empty ( $ p [ 'pid' ] ) ) { $ this -> relay -> send ( sprintf ( '{"pid":%s}' , getmypid ( ) ) , Relay :: PAYLOAD_CONTROL ) ; } // termination request if ( ! empty ( $ p [ 'stop' ] ) ) { return false ; } // parsed header $ header = $ p ; return true ; }
Handles incoming control command payload and executes it if required.

@param string $body
@param mixed  $header Exported context (if any).
@param int    $flags
@return bool True when continue processing.

@throws RoadRunnerException
Handles incoming control command payload and executes it if required .