/** * @param PromiseInterface $promise */ private function retry(PromiseInterface $promise) { if ($this->counter >= $this->params['retriesLimit']) { $promise->reject(new ThrowableProxy(new TimeoutException('No response was received during specified timeout.'))); } else { if ($this->params['retriesInterval'] > 0) { $this->counter++; $this->channel->getLoop()->addTimer($this->params['retriesInterval'], function () use($promise) { $this->send($promise); }); } else { $this->counter++; $this->channel->getLoop()->onTick(function () use($promise) { $this->send($promise); }); } } }