Cleaned up batching checks

This commit is contained in:
Dylan K. Taylor 2017-04-26 22:02:45 +01:00
parent 4d897b824b
commit bf9b8722c9
2 changed files with 6 additions and 6 deletions

View File

@ -57,6 +57,9 @@ class BatchPacket extends DataPacket{
*/
public function addPacket($packet){
if($packet instanceof DataPacket){
if(!$packet->canBeBatched()){
throw new \InvalidArgumentException(get_class($packet) . " cannot be put inside a BatchPacket");
}
if(!$packet->isEncoded){
$packet->encode();
}
@ -93,9 +96,10 @@ class BatchPacket extends DataPacket{
while(!$this->feof()){
$buf = $this->getString();
$pk = $network->getPacket(ord($buf{0}));
/*if(!$pk->canBeBatched()){
if(!$pk->canBeBatched()){
throw new \InvalidArgumentException("Received invalid " . get_class($pk) . " inside BatchPacket");
}*/
}
$pk->setBuffer($buf, 1);
$session->handleDataPacket($pk);

View File

@ -44,10 +44,6 @@ class LoginPacket extends DataPacket{
public $clientData = [];
public function canBeBatched() : bool{
return false;
}
public function canBeSentBeforeLogin() : bool{
return true;
}