mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
NetworkSession: fix some blind spots on logging
This commit is contained in:
parent
9df2ca3655
commit
94299534b3
@ -79,6 +79,7 @@ use pocketmine\PlayerInfo;
|
|||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\timings\Timings;
|
use pocketmine\timings\Timings;
|
||||||
use pocketmine\utils\BinaryDataException;
|
use pocketmine\utils\BinaryDataException;
|
||||||
|
use pocketmine\utils\TextFormat;
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\world\Position;
|
use pocketmine\world\Position;
|
||||||
use function array_map;
|
use function array_map;
|
||||||
@ -154,6 +155,7 @@ class NetworkSession{
|
|||||||
$this->setHandler(new LoginSessionHandler($this->server, $this));
|
$this->setHandler(new LoginSessionHandler($this->server, $this));
|
||||||
|
|
||||||
$this->manager->add($this);
|
$this->manager->add($this);
|
||||||
|
$this->logger->info("Session opened");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLogPrefix() : string{
|
private function getLogPrefix() : string{
|
||||||
@ -195,6 +197,7 @@ class NetworkSession{
|
|||||||
throw new \InvalidStateException("Player info has already been set");
|
throw new \InvalidStateException("Player info has already been set");
|
||||||
}
|
}
|
||||||
$this->info = $info;
|
$this->info = $info;
|
||||||
|
$this->logger->info("Player: " . TextFormat::AQUA . $info->getUsername() . TextFormat::RESET);
|
||||||
$this->logger->setPrefix($this->getLogPrefix());
|
$this->logger->setPrefix($this->getLogPrefix());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +434,7 @@ class NetworkSession{
|
|||||||
$this->interface->putPacket($this, $payload, $immediate);
|
$this->interface->putPacket($this, $payload, $immediate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function tryDisconnect(\Closure $func) : void{
|
private function tryDisconnect(\Closure $func, string $reason) : void{
|
||||||
if($this->connected and !$this->disconnectGuard){
|
if($this->connected and !$this->disconnectGuard){
|
||||||
$this->disconnectGuard = true;
|
$this->disconnectGuard = true;
|
||||||
$func();
|
$func();
|
||||||
@ -439,6 +442,7 @@ class NetworkSession{
|
|||||||
$this->setHandler(NullSessionHandler::getInstance());
|
$this->setHandler(NullSessionHandler::getInstance());
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
$this->manager->remove($this);
|
$this->manager->remove($this);
|
||||||
|
$this->logger->info("Session closed due to $reason");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +458,7 @@ class NetworkSession{
|
|||||||
$this->player->disconnect($reason, null, $notify);
|
$this->player->disconnect($reason, null, $notify);
|
||||||
}
|
}
|
||||||
$this->doServerDisconnect($reason, $notify);
|
$this->doServerDisconnect($reason, $notify);
|
||||||
});
|
}, $reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -474,7 +478,7 @@ class NetworkSession{
|
|||||||
$this->player->disconnect($reason, null, false);
|
$this->player->disconnect($reason, null, false);
|
||||||
}
|
}
|
||||||
$this->doServerDisconnect($reason, false);
|
$this->doServerDisconnect($reason, false);
|
||||||
});
|
}, $reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -486,7 +490,7 @@ class NetworkSession{
|
|||||||
public function onPlayerDestroyed(string $reason, bool $notify = true) : void{
|
public function onPlayerDestroyed(string $reason, bool $notify = true) : void{
|
||||||
$this->tryDisconnect(function() use ($reason, $notify){
|
$this->tryDisconnect(function() use ($reason, $notify){
|
||||||
$this->doServerDisconnect($reason, $notify);
|
$this->doServerDisconnect($reason, $notify);
|
||||||
});
|
}, $reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -514,7 +518,7 @@ class NetworkSession{
|
|||||||
if($this->player !== null){
|
if($this->player !== null){
|
||||||
$this->player->disconnect($reason, null, false);
|
$this->player->disconnect($reason, null, false);
|
||||||
}
|
}
|
||||||
});
|
}, $reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAuthenticationStatus(bool $authenticated, bool $authRequired, ?string $error) : bool{
|
public function setAuthenticationStatus(bool $authenticated, bool $authRequired, ?string $error) : bool{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user