Improvements
This commit is contained in:
parent
56bce59cdb
commit
6e390a92bb
@ -69,6 +69,8 @@ class Connection
|
||||
public $new_outgoing = [];
|
||||
public $pending_outgoing = [];
|
||||
public $pending_outgoing_key = 0;
|
||||
public $pending_outgoing_unencrypted = [];
|
||||
public $pending_outgoing_unencrypted_key = 0;
|
||||
public $max_incoming_id;
|
||||
public $max_outgoing_id;
|
||||
public $authorized = false;
|
||||
@ -134,7 +136,7 @@ class Connection
|
||||
if ($this->outgoing_messages[$message_id]['unencrypted']) {
|
||||
$promise = $this->outgoing_messages[$message_id]['promise'];
|
||||
\Amp\Loop::defer(function () use ($promise) {
|
||||
$promise->fail(new Exception('Restart'));
|
||||
$promise->fail(new Exception('Restart because we were reconnected'));
|
||||
});
|
||||
unset($this->new_outgoing[$message_id]);
|
||||
unset($this->outgoing_messages[$message_id]);
|
||||
|
@ -71,13 +71,13 @@ class ReadLoop extends SignalLoop
|
||||
|
||||
if ($error === -404) {
|
||||
if ($connection->temp_auth_key !== null) {
|
||||
yield $connection->reconnect();
|
||||
$API->logger->logger("WARNING: Resetting auth key in DC {$datacenter}...", \danog\MadelineProto\Logger::WARNING);
|
||||
$connection->temp_auth_key = null;
|
||||
$connection->session_id = null;
|
||||
foreach ($connection->new_outgoing as $message_id) {
|
||||
$connection->outgoing_messages[$message_id]['sent'] = 0;
|
||||
}
|
||||
yield $connection->reconnect();
|
||||
yield $API->init_authorization_async();
|
||||
} else {
|
||||
yield $connection->reconnect();
|
||||
|
@ -44,9 +44,10 @@ class WriteLoop extends ResumableSignalLoop
|
||||
|
||||
$this->startedLoop();
|
||||
$API->logger->logger("Entered write loop in DC {$datacenter}", Logger::ULTRA_VERBOSE);
|
||||
|
||||
|
||||
$please_wait = false;
|
||||
while (true) {
|
||||
if (empty($connection->pending_outgoing)) {
|
||||
if (empty($connection->pending_outgoing) || $please_wait) {
|
||||
if (yield $this->waitSignal($this->pause())) {
|
||||
$API->logger->logger("Exiting write loop in DC $datacenter");
|
||||
$this->exitedLoop();
|
||||
@ -62,7 +63,7 @@ class WriteLoop extends ResumableSignalLoop
|
||||
} else {
|
||||
$res = $this->encryptedWriteLoopAsync();
|
||||
}
|
||||
yield $res;
|
||||
$please_wait = yield $res;
|
||||
} finally {
|
||||
$this->exitedLoop();
|
||||
}
|
||||
@ -120,7 +121,7 @@ class WriteLoop extends ResumableSignalLoop
|
||||
unset($message['send_promise']);
|
||||
}
|
||||
if ($skipped_all) {
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,7 +272,7 @@ class WriteLoop extends ResumableSignalLoop
|
||||
} else {
|
||||
$API->logger->logger("NO MESSAGE SENT in DC $datacenter", \danog\MadelineProto\Logger::WARNING);
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
unset($messages);
|
||||
|
Loading…
x
Reference in New Issue
Block a user