This commit is contained in:
Daniil Gentili 2019-03-29 23:30:07 +00:00
parent b306c98e4b
commit c59aae4218
3 changed files with 17 additions and 19 deletions

View File

@ -839,16 +839,19 @@ class MTProto implements TLCallback
}
yield $dcs;
yield $this->init_authorization_async();
$this->phoneConfigWatcherId = Loop::repeat(24 * 3600 * 1000, function ($watcherId) {
if ($this->authorized === self::LOGGED_IN) {
if (!$this->phoneConfigWatcherId) $this->phoneConfigWatcherId = Loop::repeat(24 * 3600 * 1000, [$this, 'get_phone_config_async']);
yield $this->get_phone_config_async();
$this->logger->logger("Started phone config fetcher");
}
public function get_phone_config_async($watcherId = null)
{
if ($this->authorized === self::LOGGED_IN && extension_loaded('libtgvoip')) {
$this->logger->logger("Fetching phone config...");
VoIPServerConfig::updateDefault(yield $this->method_call_async_read('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]));
VoIPServerConfig::updateDefault(yield $this->method_call_async_read('phone.getCallConfig', [], ['datacenter' => $this->settings['connection_settings']['default_dc']]));
} else {
$this->logger->logger("Not fetching phone config");
}
});
VoIPServerConfig::updateDefault(yield $this->method_call_async_read('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]));
$this->logger->logger("Started phone config fetcher");
}
public function get_config($config = [], $options = [])
@ -861,7 +864,7 @@ class MTProto implements TLCallback
if ($this->config['expires'] > time()) {
return $this->config;
}
$this->config = empty($config) ? yield $this->method_call_async_read('help.getConfig', $config, empty($options) ? ['datacenter' => $this->datacenter->curdc] : $options) : $config;
$this->config = empty($config) ? yield $this->method_call_async_read('help.getConfig', $config, empty($options) ? ['datacenter' => $this->settings['connection_settings']['default_dc']] : $options) : $config;
yield $this->parse_config();
return $this->config;

View File

@ -89,9 +89,4 @@ if (class_exists('\\danog\\MadelineProto\\VoIPServerConfigInternal')) {
return array_merge(self::$_configDefault, self::$_config);
}
}
} else {
class VoIPServerConfig
{
public static function update(array $config) {}
}
}

View File

@ -123,7 +123,7 @@ trait Login
$this->authorization = $authorization;
$this->datacenter->sockets[$this->datacenter->curdc]->authorized = true;
yield $this->init_authorization_async();
VoIPServerConfig::updateDefault(yield $this->method_call_async_read('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]));
yield $this->get_phone_config_async();
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['login_ok'], \danog\MadelineProto\Logger::NOTICE);
@ -154,7 +154,7 @@ trait Login
$this->datacenter->sockets[$dc_id]->authorized = true;
$this->authorized = self::LOGGED_IN;
yield $this->init_authorization_async();
VoIPServerConfig::updateDefault(yield $this->method_call_async_read('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]));
yield $this->get_phone_config_async();
return yield $this->get_self_async();
}
@ -181,7 +181,7 @@ trait Login
$this->authorized = self::LOGGED_IN;
$this->datacenter->sockets[$this->datacenter->curdc]->authorized = true;
yield $this->init_authorization_async();
VoIPServerConfig::updateDefault(yield $this->method_call_async_read('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]));
yield $this->get_phone_config_async();
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['signup_ok'], \danog\MadelineProto\Logger::NOTICE);
@ -202,7 +202,7 @@ trait Login
$this->datacenter->sockets[$this->datacenter->curdc]->authorized = true;
yield $this->init_authorization_async();
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['login_ok'], \danog\MadelineProto\Logger::NOTICE);
VoIPServerConfig::updateDefault(yield $this->method_call_async_read('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]));
yield $this->get_phone_config_async();
return $this->authorization;
}