mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-24 20:34:02 +00:00
NullSessionHandler: possibly premature optimization
This commit is contained in:
parent
685481b172
commit
82974e0271
@ -420,7 +420,7 @@ class NetworkSession{
|
||||
$this->disconnectGuard = true;
|
||||
$func();
|
||||
$this->disconnectGuard = false;
|
||||
$this->setHandler(new NullSessionHandler());
|
||||
$this->setHandler(NullSessionHandler::getInstance());
|
||||
$this->connected = false;
|
||||
$this->manager->remove($this);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class LoginSessionHandler extends SessionHandler{
|
||||
*/
|
||||
protected function processLogin(LoginPacket $packet, bool $authRequired) : void{
|
||||
$this->server->getAsyncPool()->submitTask(new ProcessLoginTask($this->session, $packet, $authRequired, NetworkCipher::$ENABLED));
|
||||
$this->session->setHandler(new NullSessionHandler()); //drop packets received during login verification
|
||||
$this->session->setHandler(NullSessionHandler::getInstance()); //drop packets received during login verification
|
||||
}
|
||||
|
||||
protected function isCompatibleProtocol(int $protocolVersion) : bool{
|
||||
|
@ -26,6 +26,15 @@ namespace pocketmine\network\mcpe\handler;
|
||||
/**
|
||||
* Handler which simply ignores all packets received.
|
||||
*/
|
||||
class NullSessionHandler extends SessionHandler{
|
||||
final class NullSessionHandler extends SessionHandler{
|
||||
/** @var self|null */
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance() : self{
|
||||
return self::$instance ?? (self::$instance = new self);
|
||||
}
|
||||
|
||||
private function __construct(){
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user