Fix packet buffers when encoding twice

This commit is contained in:
Dylan K. Taylor 2017-08-06 13:20:56 +01:00
parent 711d62b5eb
commit d9da9accbc

View File

@ -84,6 +84,7 @@ abstract class DataPacket extends BinaryStream{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->encodeHeader();
$this->encodePayload(); $this->encodePayload();
$this->isEncoded = true; $this->isEncoded = true;
} }
@ -114,11 +115,6 @@ abstract class DataPacket extends BinaryStream{
*/ */
abstract public function handle(NetworkSession $session) : bool; abstract public function handle(NetworkSession $session) : bool;
public function reset(){
$this->encodeHeader();
$this->offset = 0;
}
public function clean(){ public function clean(){
$this->buffer = null; $this->buffer = null;
$this->isEncoded = false; $this->isEncoded = false;