mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 07:54:19 +00:00
NetworkSession: do not send packets to disconnected sessions
this is mostly harmless, since the packets land in a buffer that gets discarded, but we also need to avoid calling DataPacketSendEvent.
This commit is contained in:
parent
f7d0d16eb3
commit
80832ff763
@ -424,6 +424,9 @@ class NetworkSession{
|
||||
}
|
||||
|
||||
public function sendDataPacket(ClientboundPacket $packet, bool $immediate = false) : bool{
|
||||
if(!$this->connected){
|
||||
return false;
|
||||
}
|
||||
//Basic safety restriction. TODO: improve this
|
||||
if(!$this->loggedIn && !$packet->canBeSentBeforeLogin()){
|
||||
throw new \InvalidArgumentException("Attempted to send " . get_class($packet) . " to " . $this->getDisplayName() . " too early");
|
||||
|
Loading…
x
Reference in New Issue
Block a user