Skip to content

Commit

Permalink
Start session bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
xtrime-ru committed Jan 26, 2020
1 parent 1ecbcb5 commit abe9653
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ public function addSession(string $session, bool $startSession = false)
$instance = new MadelineProto\API($file, $settings);
$instance->async(true);
$this->instances[$session] = $instance;
if($startSession === true) {
$instance->loop(function() use($instance) {
yield $instance->start();
});
}
if (($instance->API->authorized ?? MTProto::NOT_LOGGED_IN) === MTProto::LOGGED_IN) {
$instance->setEventHandler(EventHandler::class);
Loop::defer(static function() use($instance) {
$instance->loop(['async' => true]);
});
} elseif($startSession === true) {
$instance->loop(function() use($instance) {
yield $instance->start();
});
}
}

Expand Down

0 comments on commit abe9653

Please sign in to comment.