This commit is contained in:
Daniil Gentili 2017-05-31 10:22:42 +01:00
parent 1858b7f8c8
commit 56ae262738
2 changed files with 12 additions and 8 deletions

View File

@ -34,8 +34,8 @@ class DataCenter extends \Volatile
{
$this->dclist = $dclist;
$this->settings = $settings;
foreach ($this->sockets as $socket) {
$socket->close_and_reopen();
foreach ($this->sockets as $key => $socket) {
if ($socket instanceof Connection) $socket->close_and_reopen(); else unset($this->sockets[$key]);
}
}

View File

@ -237,6 +237,7 @@ class MTProto extends \Volatile
$this->datacenter->curdc = 2;
if (!isset($this->authorization['user']['bot']) || !$this->authorization['user']['bot']) {
try {
$nearest_dc = $this->method_call('help.getNearestDc', [], ['datacenter' => $this->datacenter->curdc]);
\danog\MadelineProto\Logger::log(["We're in ".$nearest_dc['country'].', current dc is '.$nearest_dc['this_dc'].', nearest dc is '.$nearest_dc['nearest_dc'].'.'], Logger::NOTICE);
@ -245,6 +246,9 @@ class MTProto extends \Volatile
$this->settings['connection_settings']['default_dc'] = $nearest_dc['nearest_dc'];
$this->should_serialize = true;
}
} catch (RPCErrorException $e) {
if ($e->rpc !== "BOT_METHOD_INVALID") throw $e;
}
}
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
$this->v = $this->getV();