1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-23 03:11:12 +01:00

BC and media DC fixes

This commit is contained in:
Daniil Gentili 2023-01-26 15:44:42 +01:00
parent 906091bbaa
commit a20c5f9c67
3 changed files with 8 additions and 30 deletions

View File

@ -178,6 +178,12 @@ abstract class AsyncTools extends StrTools
}
if ($yielded instanceof Generator) {
$yielded = self::consumeGenerator($yielded);
} elseif (is_array($yielded)) {
$yielded = array_map(
fn ($v) => $v instanceof Generator ? self::consumeGenerator($v) : $v,
$yielded
);
$yielded = $g->send($yielded);
} else {
$yielded = $g->send($yielded);
}

View File

@ -434,8 +434,7 @@ final class DataCenterConnection implements JsonSerializable
$this->API->logger->logger("Trying shared connection via {$ctx} ({$id})");
$this->datacenter = $ctx->getDc();
$media = $ctx->isMedia() || $ctx->isCDN();
$count = $media ? $this->API->getSettings()->getConnection()->getMinMediaSocketCount() : 1;
if ($count > 1) {
if ($media) {
if (!$this->robinLoop) {
$this->robinLoop = new PeriodicLoopInternal(
$this->API,
@ -454,7 +453,7 @@ final class DataCenterConnection implements JsonSerializable
return;
}
$this->ctx = $ctx->getCtx();
$this->connectMore($count);
$this->connectMore(1);
$this->restoreBackup();
$f = new DeferredFuture;
$f->complete();

View File

@ -28,10 +28,6 @@ use danog\MadelineProto\Stream\Transport\WsStream;
*/
final class Connection extends SettingsAbstract
{
/**
* Minimum media socket count.
*/
protected int $minMediaSocketCount = 5;
/**
* Maximum media socket count.
*/
@ -114,9 +110,6 @@ final class Connection extends SettingsAbstract
$this->setSslSubdomains($settings['connection']['ssl_subdomains']);
}
$settings = $settings['connection_settings'] ?? [];
if (isset($settings['media_socket_count']['min'])) {
$this->setMinMediaSocketCount($settings['media_socket_count']['min']);
}
if (isset($settings['media_socket_count']['max'])) {
$this->setMaxMediaSocketCount($settings['media_socket_count']['max']);
}
@ -338,26 +331,6 @@ final class Connection extends SettingsAbstract
return $this;
}
/**
* Get minimum media socket count.
*/
public function getMinMediaSocketCount(): int
{
return $this->minMediaSocketCount;
}
/**
* Set minimum media socket count.
*
* @param int $minMediaSocketCount Minimum media socket count.
*/
public function setMinMediaSocketCount(int $minMediaSocketCount): self
{
$this->minMediaSocketCount = $minMediaSocketCount;
return $this;
}
/**
* Get maximum media socket count.
*/