mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 04:00:29 +00:00
PrepareEncryptionTask: remove cyclic dependency on NetworkSession
This commit is contained in:
@@ -530,25 +530,23 @@ class NetworkSession{
|
||||
|
||||
if($this->manager->kickDuplicates($this)){
|
||||
if(NetworkCipher::$ENABLED){
|
||||
$this->server->getAsyncPool()->submitTask(new PrepareEncryptionTask($this, $clientPubKey));
|
||||
$this->server->getAsyncPool()->submitTask(new PrepareEncryptionTask($clientPubKey, function(string $encryptionKey, string $handshakeJwt) : void{
|
||||
if(!$this->connected){
|
||||
return;
|
||||
}
|
||||
$this->sendDataPacket(ServerToClientHandshakePacket::create($handshakeJwt), true); //make sure this gets sent before encryption is enabled
|
||||
|
||||
$this->cipher = new NetworkCipher($encryptionKey);
|
||||
|
||||
$this->setHandler(new HandshakePacketHandler($this));
|
||||
$this->logger->debug("Enabled encryption");
|
||||
}));
|
||||
}else{
|
||||
$this->onLoginSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function enableEncryption(string $encryptionKey, string $handshakeJwt) : void{
|
||||
if(!$this->connected){
|
||||
return;
|
||||
}
|
||||
$this->sendDataPacket(ServerToClientHandshakePacket::create($handshakeJwt), true); //make sure this gets sent before encryption is enabled
|
||||
|
||||
$this->cipher = new NetworkCipher($encryptionKey);
|
||||
|
||||
$this->setHandler(new HandshakePacketHandler($this));
|
||||
$this->logger->debug("Enabled encryption");
|
||||
}
|
||||
|
||||
public function onLoginSuccess() : void{
|
||||
$this->loggedIn = true;
|
||||
|
||||
|
Reference in New Issue
Block a user