This commit is contained in:
Daniil Gentili 2017-01-18 10:24:57 +01:00
parent bd40ca528a
commit d8d727d68a
2 changed files with 7 additions and 4 deletions

View File

@ -47,6 +47,7 @@ class API extends APIFactory
public function __sleep() public function __sleep()
{ {
$this->API->reset_session(false);
return ['API']; return ['API'];
} }

View File

@ -232,12 +232,14 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
//} //}
} }
public function reset_session() public function reset_session($de = true)
{ {
foreach ($this->datacenter->sockets as $id => &$socket) { foreach ($this->datacenter->sockets as $id => &$socket) {
\danog\MadelineProto\Logger::log('Resetting session id and seq_no in DC '.$id.'...'); if ($de) {
$socket->session_id = \danog\MadelineProto\Tools::random(8); \danog\MadelineProto\Logger::log('Resetting session id and seq_no in DC '.$id.'...');
$socket->seq_no = 0; $socket->session_id = \danog\MadelineProto\Tools::random(8);
$socket->seq_no = 0;
}
$socket->incoming_messages = []; $socket->incoming_messages = [];
$socket->outgoing_messages = []; $socket->outgoing_messages = [];
$socket->new_outgoing = []; $socket->new_outgoing = [];