Skip to content

Commit

Permalink
Merge pull request #132 from manuelm/master
Browse files Browse the repository at this point in the history
Don't append payload per byte unless necessary
  • Loading branch information
sirn-se authored Feb 24, 2021
2 parents b932494 + 3389629 commit caa1610
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,15 @@ protected function sendFragment(bool $final, string $payload, string $opcode, bo
$mask .= chr(rand(0, 255));
}
$data .= $mask;
}

// Append payload to frame:
for ($i = 0; $i < $payload_length; $i++) {
$data .= ($masked === true) ? $payload[$i] ^ $mask[$i % 4] : $payload[$i];
// Append payload to frame:
for ($i = 0; $i < $payload_length; $i++) {
$data .= $payload[$i] ^ $mask[$i % 4];
}
} else {
$data .= $payload;
}

$this->write($data);
$this->logger->debug("Sent '{$opcode}' frame", [
'opcode' => $opcode,
Expand Down

0 comments on commit caa1610

Please sign in to comment.