mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
ProcessLoginTask no longer depends on NetworkSession
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user