public function onJobMessage(array $message) : bool
    {
        $jobName = $message[0];
        $jobId = $message[1];
        $workerId = $message[2];
        $payload = $message[3];

        // Skip if job is assigned to another worker:
        if ($workerId !== $this->workerId) {
            return false;
        }

        // Skip if worker can not handle the requested job
        if (!isset($this->callbacks[$jobName])) {
            throw new WorkerException('No callback found for requested job.');
        }

        // Switch to busy state handle job and switch back to idle state:
        $this->jobId = $jobId;
        $this->setState(Worker::WORKER_STATE_BUSY);
        $result = call_user_func($this->callbacks[$jobName], $payload);
        $this->onJobCompleted($result);
        $this->setState(Worker::WORKER_STATE_IDLE);
        return true;
    }
public function onJobMessage(array $message) : bool
    {
        $jobName = $message[0];
        $jobId = $message[1];
        $workerId = $message[2];
        $payload = $message[3];

        // Skip if job is assigned to another worker:
        if ($workerId !== $this->workerId) {
            return false;
        }

        // Skip if worker can not handle the requested job
        if (!isset($this->callbacks[$jobName])) {
            throw new WorkerException('No callback found for requested job.');
        }

        // Switch to busy state handle job and switch back to idle state:
        $this->jobId = $jobId;
        $this->setState(Worker::WORKER_STATE_BUSY);
        $result = call_user_func($this->callbacks[$jobName], $payload);
        $this->onJobCompleted($result);
        $this->setState(Worker::WORKER_STATE_IDLE);
        return true;
    }
public function onJobMessage ( array $ message ) : bool { $ jobName = $ message [ 0 ] ; $ jobId = $ message [ 1 ] ; $ workerId = $ message [ 2 ] ; $ payload = $ message [ 3 ] ; // Skip if job is assigned to another worker: if ( $ workerId !== $ this -> workerId ) { return false ; } // Skip if worker can not handle the requested job if ( ! isset ( $ this -> callbacks [ $ jobName ] ) ) { throw new WorkerException ( 'No callback found for requested job.' ) ; } // Switch to busy state handle job and switch back to idle state: $ this -> jobId = $ jobId ; $ this -> setState ( Worker :: WORKER_STATE_BUSY ) ; $ result = call_user_func ( $ this -> callbacks [ $ jobName ] , $ payload ) ; $ this -> onJobCompleted ( $ result ) ; $ this -> setState ( Worker :: WORKER_STATE_IDLE ) ; return true ; }
Handles job requests received from server.

@throws WorkerException
@param array $message
@return bool
Handles job requests received from server .