ProcessLoginTask no longer depends on NetworkSession

This commit is contained in:
Dylan K. Taylor
2020-04-22 13:30:37 +01:00
parent dd37d286f0
commit 35d656c6e5
3 changed files with 38 additions and 15 deletions

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\handler;
use pocketmine\entity\Skin;
use Mdanter\Ecc\Crypto\Key\PublicKeyInterface;
use pocketmine\event\player\PlayerPreLoginEvent;
use pocketmine\network\BadPacketException;
use pocketmine\network\mcpe\auth\ProcessLoginTask;
@ -59,14 +59,25 @@ class LoginPacketHandler extends PacketHandler{
* @phpstan-var \Closure(PlayerInfo) : void
*/
private $playerInfoConsumer;
/**
* @var \Closure
* @phpstan-var \Closure(bool, bool, ?string, ?PublicKeyInterface) : void
*/
private $authCallback;
/**
* @phpstan-param \Closure(PlayerInfo) : void $playerInfoConsumer
* @phpstan-param \Closure(bool $isAuthenticated, bool $authRequired, ?string $error, ?PublicKeyInterface $clientPubKey) : void $authCallback
*/
public function __construct(Server $server, NetworkSession $session, \Closure $playerInfoConsumer){
public function __construct(Server $server, NetworkSession $session, \Closure $playerInfoConsumer, \Closure $authCallback){
$this->session = $session;
$this->server = $server;
$this->playerInfoConsumer = $playerInfoConsumer;
$this->authCallback = $authCallback;
}
private static function dummy() : void{
echo PublicKeyInterface::class; //this prevents the import getting removed by tools that don't understand phpstan
}
public function handleLogin(LoginPacket $packet) : bool{
@ -182,7 +193,7 @@ class LoginPacketHandler extends PacketHandler{
* @throws \InvalidArgumentException
*/
protected function processLogin(LoginPacket $packet, bool $authRequired) : void{
$this->server->getAsyncPool()->submitTask(new ProcessLoginTask($this->session, $packet, $authRequired));
$this->server->getAsyncPool()->submitTask(new ProcessLoginTask($packet, $authRequired, $this->authCallback));
$this->session->setHandler(NullPacketHandler::getInstance()); //drop packets received during login verification
}