protected function requestCbProducer($opcode, $data, $reply = false, $sentcb = null)
{
return function ($conn) use($opcode, $data, $reply, $sentcb) {
if (!$conn || $conn->isFinished()) {
if ($this->finished) {
if ($sentcb !== null) {
$sentcb(false);
}
} else {
$this->getConnectionRR($this->requestCbProducer($opcode, $data, $reply, $sentcb));
}
return;
}
$reqId = ++$conn->lastReqId;
$this->lastRequestConnection = $conn;
$conn->write(pack('VVVV', mb_orig_strlen($data) + 16, $reqId, 0, $opcode));
$conn->write($data);
if ($reply) {
$conn->setFree(false);
}
if ($sentcb !== null) {
$sentcb($conn, $reqId);
}
};
}