mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 20:14:31 +00:00
HandshakePacketHandler no longer depends on NetworkSession
This commit is contained in:
@@ -548,7 +548,9 @@ class NetworkSession{
|
||||
|
||||
$this->cipher = new NetworkCipher($encryptionKey);
|
||||
|
||||
$this->setHandler(new HandshakePacketHandler($this));
|
||||
$this->setHandler(new HandshakePacketHandler(function() : void{
|
||||
$this->onLoginSuccess();
|
||||
}));
|
||||
$this->logger->debug("Enabled encryption");
|
||||
}));
|
||||
}else{
|
||||
@@ -557,7 +559,7 @@ class NetworkSession{
|
||||
}
|
||||
}
|
||||
|
||||
public function onLoginSuccess() : void{
|
||||
private function onLoginSuccess() : void{
|
||||
$this->loggedIn = true;
|
||||
|
||||
$this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::LOGIN_SUCCESS));
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\handler;
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
|
||||
|
||||
/**
|
||||
@@ -31,15 +30,21 @@ use pocketmine\network\mcpe\protocol\ClientToServerHandshakePacket;
|
||||
*/
|
||||
class HandshakePacketHandler extends PacketHandler{
|
||||
|
||||
/** @var NetworkSession */
|
||||
private $session;
|
||||
/**
|
||||
* @var \Closure
|
||||
* @phpstan-var \Closure() : void
|
||||
*/
|
||||
private $onHandshakeCompleted;
|
||||
|
||||
public function __construct(NetworkSession $session){
|
||||
$this->session = $session;
|
||||
/**
|
||||
* @phpstan-param \Closure() : void $onHandshakeCompleted
|
||||
*/
|
||||
public function __construct(\Closure $onHandshakeCompleted){
|
||||
$this->onHandshakeCompleted = $onHandshakeCompleted;
|
||||
}
|
||||
|
||||
public function handleClientToServerHandshake(ClientToServerHandshakePacket $packet) : bool{
|
||||
$this->session->onLoginSuccess();
|
||||
($this->onHandshakeCompleted)();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user