Fixed pts bugs, created PTSException

This commit is contained in:
Daniil Gentili 2017-05-28 00:35:50 +01:00
parent 814c030296
commit 4ea3b83ae1
5 changed files with 30 additions and 6 deletions

View File

@ -458,6 +458,8 @@ MadelineProto can throw lots of different exceptions:
* \danog\MadelineProto\NothingInTheSocketException - Thrown if no data can be read from the TCP socket
* \danog\MadelineProto\PTSException - Thrown if the PTS is unrecoverably corrupted
* \danog\MadelineProto\SecurityException - Thrown on security problems (invalid params during generation of auth key or similar)
* \danog\MadelineProto\TL\Conversion\Exception - Thrown if some param/object can't be converted to/from bot API/TD/TD-CLI format (this includes markdown/html parsing)

View File

@ -462,6 +462,8 @@ MadelineProto can throw lots of different exceptions:
* \danog\MadelineProto\NothingInTheSocketException - Thrown if no data can be read from the TCP socket
* \danog\MadelineProto\PTSException - Thrown if the PTS is unrecoverably corrupted
* \danog\MadelineProto\SecurityException - Thrown on security problems (invalid params during generation of auth key or similar)
* \danog\MadelineProto\TL\Conversion\Exception - Thrown if some param/object can't be converted to/from bot API/TD/TD-CLI format (this includes markdown/html parsing)

View File

@ -96,13 +96,14 @@ trait ResponseHandler
unset($this->datacenter->sockets[$datacenter]->new_incoming[$current_msg_id]);
unset($this->datacenter->sockets[$datacenter]->new_outgoing[$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['req_msg_id']]);
break;
/*
case 'rpc_error':
$this->check_in_seq_no($datacenter, $current_msg_id);
$only_updates = false;
$aargs = ['datacenter' => &$datacenter];
$this->handle_rpc_error($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content'], $aargs);
unset($aargs);
break;
break;*/
case 'bad_server_salt':
case 'bad_msg_notification':
@ -320,10 +321,8 @@ trait ResponseHandler
public function handle_rpc_error($server_answer, &$aargs)
{
if (in_array($server_answer['error_message'], ['PERSISTENT_TIMESTAMP_EMPTY', 'PERSISTENT_TIMESTAMP_OUTDATED'])) {
$this->got_state = false;
$this->get_update_state();
throw new \danog\MadelineProto\Exception('Update the timestamp pls');
if (in_array($server_answer['error_message'], ['PERSISTENT_TIMESTAMP_EMPTY', 'PERSISTENT_TIMESTAMP_OUTDATED', 'PERSISTENT_TIMESTAMP_INVALID'])) {
throw new \danog\MadelineProto\PTSException($server_answer['error_message']);
}
switch ($server_answer['error_code']) {
case 303:

View File

@ -233,7 +233,11 @@ trait UpdateHandler
$this->get_update_state()['pending_pts_updates'] = [];
$this->get_update_state()['pending_seq_updates'] = [];
}
$difference = $this->method_call('updates.getDifference', ['pts' => $this->get_update_state()['pts'], 'date' => $this->get_update_state()['date'], 'qts' => $this->get_update_state()['qts']], ['datacenter' => $this->datacenter->curdc]);
while (!isset($difference)) {
try {
$difference = $this->method_call('updates.getDifference', ['pts' => $this->get_update_state()['pts'], 'date' => $this->get_update_state()['date'], 'qts' => $this->get_update_state()['qts']], ['datacenter' => $this->datacenter->curdc]);
} catch (\danog\MadelineProto\PTSException $e) { $this->got_state = false; }
}
\danog\MadelineProto\Logger::log(['Got '.$difference['_']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
$this->get_update_state()['sync_loading'] = false;

View File

@ -0,0 +1,17 @@
<?php
/*
Copyright 2016-2017 Daniil Gentili
(https://daniil.it)
This file is part of MadelineProto.
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with MadelineProto.
If not, see <http://www.gnu.org/licenses/>.
*/
namespace danog\MadelineProto;
class PTSException extends \Exception
{
}