sendWithResponse
This commit is contained in:
@ -70,7 +70,7 @@ abstract class Connection
|
|||||||
|
|
||||||
$this->logger->info('Feature Negotiation: '.http_build_query($this->features));
|
$this->logger->info('Feature Negotiation: '.http_build_query($this->features));
|
||||||
|
|
||||||
$this->send('IDENTIFY '.PHP_EOL.$size.$body)->getResponse()->okOrFail();
|
$this->sendWithResponse('IDENTIFY '.PHP_EOL.$size.$body)->okOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,8 +142,10 @@ abstract class Connection
|
|||||||
return new Response(new ByteBuffer($socket->read($size)));
|
return new Response(new ByteBuffer($socket->read($size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getResponse(): Response
|
protected function sendWithResponse(string $buffer): Response
|
||||||
{
|
{
|
||||||
|
$this->send($buffer);
|
||||||
|
|
||||||
$response = $this->receive(0.1);
|
$response = $this->receive(0.1);
|
||||||
|
|
||||||
if (null === $response) {
|
if (null === $response) {
|
||||||
|
@ -15,7 +15,7 @@ class Consumer extends Connection
|
|||||||
{
|
{
|
||||||
$buffer = sprintf('SUB %s %s', $topic, $channel).PHP_EOL;
|
$buffer = sprintf('SUB %s %s', $topic, $channel).PHP_EOL;
|
||||||
|
|
||||||
$this->send($buffer)->getResponse()->okOrFail();
|
$this->sendWithResponse($buffer)->okOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ final class Producer extends Connection
|
|||||||
|
|
||||||
$buffer = 'PUB '.$topic.PHP_EOL.$size.$body;
|
$buffer = 'PUB '.$topic.PHP_EOL.$size.$body;
|
||||||
|
|
||||||
$this->send($buffer)->getResponse()->okOrFail();
|
$this->sendWithResponse($buffer)->okOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ final class Producer extends Connection
|
|||||||
|
|
||||||
$buffer = 'MPUB '.$topic.PHP_EOL.$size.$num.$mb;
|
$buffer = 'MPUB '.$topic.PHP_EOL.$size.$num.$mb;
|
||||||
|
|
||||||
$this->send($buffer)->getResponse()->okOrFail();
|
$this->sendWithResponse($buffer)->okOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +53,6 @@ final class Producer extends Connection
|
|||||||
|
|
||||||
$buffer = sprintf('DPUB %s %s', $topic, $deferTime).PHP_EOL.$size.$body;
|
$buffer = sprintf('DPUB %s %s', $topic, $deferTime).PHP_EOL.$size.$body;
|
||||||
|
|
||||||
$this->send($buffer)->getResponse()->okOrFail();
|
$this->sendWithResponse($buffer)->okOrFail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user