Skip to content

Commit

Permalink
#52: Change vars from snake-case to camel-case
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Dec 3, 2020
1 parent f101b60 commit 0f7687e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/Components/WSClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ private function validateResponse(ClientConfig $config, string $pathWithQuery, s
}

$keyAccept = trim($matches[1]);
$expectedResonse = base64_encode(pack('H*', sha1($key . self::SERVER_KEY_ACCEPT)));
if ($keyAccept !== $expectedResonse) {
$expectedResponse = base64_encode(pack('H*', sha1($key . self::SERVER_KEY_ACCEPT)));
if ($keyAccept !== $expectedResponse) {
throw new ConnectionException('Server sent bad upgrade response.',
CommonsContract::CLIENT_INVALID_UPGRADE_RESPONSE);
}
Expand Down Expand Up @@ -129,14 +129,14 @@ protected function receiveFragment()
$final = (bool)(ord($data[0]) & 1 << 7);

// Parse opcode
$opcode_int = ord($data[0]) & 31; // Bits 4-7
$opcode_ints = array_flip(self::$opcodes);
if (!array_key_exists($opcode_int, $opcode_ints)) {
throw new ConnectionException("Bad opcode in websocket frame: $opcode_int",
$opcodeInt = ord($data[0]) & 31; // Bits 4-7
$opcodeInts = array_flip(self::$opcodes);
if (!array_key_exists($opcodeInt, $opcodeInts)) {
throw new ConnectionException("Bad opcode in websocket frame: $opcodeInt",
CommonsContract::CLIENT_BAD_OPCODE);
}

$opcode = $opcode_ints[$opcode_int];
$opcode = $opcodeInts[$opcodeInt];

// record the opcode if we are not receiving a continutation fragment
if ($opcode !== 'continuation') {
Expand Down
6 changes: 3 additions & 3 deletions src/Components/WscMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,13 @@ public function receive()
public function close(int $status = 1000, string $message = 'ttfn')
{
$statusBin = sprintf('%016b', $status);
$status_str = '';
$statusStr = '';

foreach (str_split($statusBin, 8) as $binstr) {
$status_str .= chr(bindec($binstr));
$statusStr .= chr(bindec($binstr));
}

$this->send($status_str . $message, CommonsContract::EVENT_TYPE_CLOSE);
$this->send($statusStr . $message, CommonsContract::EVENT_TYPE_CLOSE);
$this->isClosing = true;

return $this->receive(); // Receiving a close frame will close the socket now.
Expand Down

0 comments on commit 0f7687e

Please sign in to comment.