src/Worker.php
public function sendPayload($data)
    {
    	// if not forked yet
		if (!$this->simulation && $this->pid === null) {
			$this->start();
		}

        $this->remainingPayloadsCounter++;
        $this->state = self::RUNNING;

        if ($this->simulation) {
			$result = $this->sentPayloadsCounter++;
			$this->simulationBuffer[$result] = $this->onPayload($data);
			$this->state = self::IDLE;
			return $result;
		}

		$data = serialize($data);
		// write payload to socket
		socket_write($this->toChild, pack('N', strlen($data)));
		socket_write($this->toChild, $data);

        return $this->sentPayloadsCounter++;
    }
public function sendPayload($data)
    {
    	// if not forked yet
		if (!$this->simulation && $this->pid === null) {
			$this->start();
		}

        $this->remainingPayloadsCounter++;
        $this->state = self::RUNNING;

        if ($this->simulation) {
			$result = $this->sentPayloadsCounter++;
			$this->simulationBuffer[$result] = $this->onPayload($data);
			$this->state = self::IDLE;
			return $result;
		}

		$data = serialize($data);
		// write payload to socket
		socket_write($this->toChild, pack('N', strlen($data)));
		socket_write($this->toChild, $data);

        return $this->sentPayloadsCounter++;
    }
Sends payload to worker
@param mixed $data
@return int Serial number of payload
@throws \Exception