Skip to content

Commit

Permalink
Fixed not calling _resetFrameData before yielding the event
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Meijer committed Jun 17, 2020
1 parent da9d677 commit cc01eb1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/PHPWebSockets/AConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,18 @@ protected function _handlePacket(string $newData) : \Generator {

if ($headers[Framer::IND_FIN]) {

yield new Update\Read(Update\Read::C_READ, $this, $this->_partialMessageOpcode, $this->_partialMessage, $this->_partialMessageStream);

$newMessageOpCode = $this->_partialMessageOpcode;
$newMessageData = $this->_partialMessage;
$newMessageStream = $this->_partialMessageStream;

/*
* We have to call _resetFrameData before yielding the update
* If we don't, and the handler of the update tries to send and wait for a new reply we'd error with a C_READ_INVALID_PAYLOAD since we assume the message we're yielding the event for hasn't been completed yet
*/
$this->_resetFrameData();

yield new Update\Read(Update\Read::C_READ, $this, $newMessageOpCode, $newMessageData, $newMessageStream);

}

break;
Expand Down

0 comments on commit cc01eb1

Please sign in to comment.