sendWithResponse

This commit is contained in:
2021-01-23 03:21:09 +03:00
parent 5d407480db
commit 54d9374478
3 changed files with 8 additions and 6 deletions

View File

@@ -70,7 +70,7 @@ abstract class Connection
$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)));
}
protected function getResponse(): Response
protected function sendWithResponse(string $buffer): Response
{
$this->send($buffer);
$response = $this->receive(0.1);
if (null === $response) {

View File

@@ -15,7 +15,7 @@ class Consumer extends Connection
{
$buffer = sprintf('SUB %s %s', $topic, $channel).PHP_EOL;
$this->send($buffer)->getResponse()->okOrFail();
$this->sendWithResponse($buffer)->okOrFail();
}
/**

View File

@@ -21,7 +21,7 @@ final class Producer extends Connection
$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;
$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;
$this->send($buffer)->getResponse()->okOrFail();
$this->sendWithResponse($buffer)->okOrFail();
}
}