This commit is contained in:
Daniil Gentili 2017-11-08 13:35:10 +03:00
parent abdddc42cc
commit 039bca985f
No known key found for this signature in database
GPG Key ID: 259900308520B573
4 changed files with 14 additions and 9 deletions

View File

@ -105,7 +105,7 @@ class Logger
self::$BIG_ENDIAN = (pack('L', 1) === pack('N', 1));
self::$bigint = PHP_INT_SIZE < 8;
preg_match('/const V = (\d+);/', file_get_contents('https://raw.githubusercontent.com/danog/MadelineProto/master/src/danog/MadelineProto/MTProto.php'), $matches);
preg_match('/const V = (\d+);/', @file_get_contents('https://raw.githubusercontent.com/danog/MadelineProto/master/src/danog/MadelineProto/MTProto.php'), $matches);
if (isset($matches[1]) && \danog\MadelineProto\MTProto::V < (int) $matches[1]) {
throw new \danog\MadelineProto\Exception(hex2bin(\danog\MadelineProto\Lang::$current_lang['v_error']), 0, null, 'MadelineProto', 1);

View File

@ -190,6 +190,8 @@ class MTProto
public $setdem = false;
public $storage = [];
private $emojis;
private $postpone_updates = false;
public function ___construct($settings = [])
{
@ -295,7 +297,7 @@ class MTProto
}
// Detect ipv6
$this->ipv6 = (bool) strlen(@file_get_contents('http://ipv6.test-ipv6.com/', false, stream_context_create(['http' => ['timeout' => 1]]))) > 0;
preg_match('/const V = (\d+);/', file_get_contents('https://raw.githubusercontent.com/danog/MadelineProto/master/src/danog/MadelineProto/MTProto.php'), $matches);
preg_match('/const V = (\d+);/', @file_get_contents('https://raw.githubusercontent.com/danog/MadelineProto/master/src/danog/MadelineProto/MTProto.php'), $matches);
$keys = array_keys((array) get_object_vars($this));
if (count($keys) !== count(array_unique($keys))) {
throw new Bug74586Exception();
@ -714,6 +716,7 @@ class MTProto
public function sync_authorization($authorized_dc)
{
$this->updates_state['sync_loading'] = true;
$this->postpone_updates = true;
try {
foreach ($this->datacenter->sockets as $new_dc => $socket) {
@ -733,6 +736,7 @@ class MTProto
$authorization = $this->method_call('auth.importAuthorization', $exported_authorization, ['datacenter' => $new_dc]);
}
} finally {
$this->postpone_updates = false;
$this->updates_state['sync_loading'] = false;
}

View File

@ -354,7 +354,7 @@ trait ResponseHandler
public function handle_pending_updates()
{
if ($this->updates_state['sync_loading']) {
if ($this->postpone_updates) {
return false;
}
if (count($this->pending_updates)) {
@ -370,14 +370,13 @@ trait ResponseHandler
{
if (!$this->settings['updates']['handle_updates']) {
return;
}/*
if ($this->updates_state["sync_loading"]) {
\danog\MadelineProto\Logger::log(['Getting state, handle later'], \danog\MadelineProto\Logger::VERBOSE);
var_dump($updates);
}
if ($this->postpone_updates) {
\danog\MadelineProto\Logger::log(['Postpone update handling'], \danog\MadelineProto\Logger::VERBOSE);
$this->pending_updates[] = $updates;
return false;
}*/
}
$this->handle_pending_updates();
\danog\MadelineProto\Logger::log(['Parsing updates received via the socket...'], \danog\MadelineProto\Logger::VERBOSE);
$opts = [];
foreach (['date', 'seq', 'seq_start'] as $key) {

View File

@ -29,6 +29,7 @@ trait DialogHandler
$datacenter = $this->datacenter->curdc;
$peers = [];
$this->postpone_updates = true;
try {
while ($this->dialog_params['count'] < $res['count']) {
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['getting_dialogs']]);
@ -47,6 +48,7 @@ trait DialogHandler
}
}
} finally {
$this->postpone_updates = false;
$this->updates_state['sync_loading'] = false;
}