mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-25 04:44:03 +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{
|
public function sendDataPacket(ClientboundPacket $packet, bool $immediate = false) : bool{
|
||||||
|
if(!$this->connected){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//Basic safety restriction. TODO: improve this
|
//Basic safety restriction. TODO: improve this
|
||||||
if(!$this->loggedIn && !$packet->canBeSentBeforeLogin()){
|
if(!$this->loggedIn && !$packet->canBeSentBeforeLogin()){
|
||||||
throw new \InvalidArgumentException("Attempted to send " . get_class($packet) . " to " . $this->getDisplayName() . " too early");
|
throw new \InvalidArgumentException("Attempted to send " . get_class($packet) . " to " . $this->getDisplayName() . " too early");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user