Use first-class closures in more places

This commit is contained in:
Dylan K. Taylor
2023-07-19 13:56:48 +01:00
parent 537721fe7d
commit 914dd90b3d
5 changed files with 9 additions and 23 deletions

View File

@ -197,7 +197,7 @@ class NetworkSession{
$this->setHandler(new SessionStartPacketHandler(
$this,
fn() => $this->onSessionStartSuccess()
$this->onSessionStartSuccess(...)
));
$this->manager->add($this);
@ -787,9 +787,7 @@ class NetworkSession{
$this->cipher = EncryptionContext::fakeGCM($encryptionKey);
$this->setHandler(new HandshakePacketHandler(function() : void{
$this->onServerLoginSuccess();
}));
$this->setHandler(new HandshakePacketHandler($this->onServerLoginSuccess(...)));
$this->logger->debug("Enabled encryption");
}));
}else{
@ -818,9 +816,7 @@ class NetworkSession{
public function notifyTerrainReady() : void{
$this->logger->debug("Sending spawn notification, waiting for spawn response");
$this->sendDataPacket(PlayStatusPacket::create(PlayStatusPacket::PLAYER_SPAWN));
$this->setHandler(new SpawnResponsePacketHandler(function() : void{
$this->onClientSpawnResponse();
}));
$this->setHandler(new SpawnResponsePacketHandler($this->onClientSpawnResponse(...)));
}
private function onClientSpawnResponse() : void{