public function awaitCommand(string $queueName, int $time = null) : ReceivedCommand
{
$id = $this->adapter->bRPopLPush("{$this->namespace}:{$queueName}:queue", "{$this->namespace}:{$queueName}:receiving", $time ?? 0);
if (empty($id)) {
throw new TimeoutException();
}
$serialized = $this->evalScript('receive_message', [$this->namespace, $queueName, $id]);
if (empty($serialized)) {
throw new ConcurrencyException(sprintf('Cannot currently receive command %s.', $id));
}
return new ReceivedCommand($queueName, $id, $serialized);
}