Improve cb

This commit is contained in:
Daniil Gentili 2019-12-29 23:30:02 +00:00
parent 62dfaa0abe
commit e46e707702
2 changed files with 7 additions and 3 deletions

View File

@ -321,6 +321,8 @@ trait ResponseHandler
if (isset($request['promise']) && \is_object($request['promise'])) {
Loop::defer(function () use (&$request, $data) {
if (isset($request['promise'])) {
$this->logger->logger('Rejecting: '.(isset($request['_']) ? $request['_'] : '-'));
$promise = $request['promise'];
unset($request['promise']);
try {
@ -521,7 +523,7 @@ trait ResponseHandler
if (\is_numeric($seconds) && $seconds < $limit) {
//$this->gotResponseForOutgoingMessageId($request_id);
$this->logger->logger('Flood, waiting '.$seconds.' seconds before repeating async call...', \danog\MadelineProto\Logger::NOTICE);
$this->logger->logger('Flood, waiting '.$seconds.' seconds before repeating async call of '.($request['_'] ?? '').'...', \danog\MadelineProto\Logger::NOTICE);
$request['sent'] += $seconds;
Loop::delay($seconds * 1000, [$this, 'methodRecall'], ['message_id' => $request_id, ]);

View File

@ -470,13 +470,15 @@ trait Files
/**
* Read callback, called when the chunk is read and fully resent.
*
* @param mixed ...$params Params to be passed to cb
*
* @return void
*/
public function callback(): void
public function callback(...$params): void
{
$this->read[$this->offset++]->resolve();
if ($this->cb) {
Tools::callFork(($this->cb)());
Tools::callFork(($this->cb)(...$params));
}
}
};