Code cleanup, return value fix, comments
This commit is contained in:
@ -221,19 +221,33 @@ class WebSocketConnection implements WebSocketInterface
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see writeBinary() to write binary frames as opposed to text frames.
|
||||
*/
|
||||
public function write($data)
|
||||
{
|
||||
return $this->send(self::OP_FRAME_TEXT, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write binary frames.
|
||||
*
|
||||
* @param string $data
|
||||
* @return bool
|
||||
*/
|
||||
public function writeBinary($data)
|
||||
{
|
||||
return $this->send(self::OP_FRAME_BINARY, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode and send a frame.
|
||||
*
|
||||
* @param int $opcode
|
||||
* @param string $data
|
||||
* @param bool $final
|
||||
* @param bool $masked
|
||||
* @return bool
|
||||
*/
|
||||
public function send(int $opcode, string $data, bool $final = true, bool $masked = false)
|
||||
{
|
||||
@ -245,9 +259,7 @@ class WebSocketConnection implements WebSocketInterface
|
||||
'masked' => $masked
|
||||
]);
|
||||
|
||||
$this->outStream->write($frame);
|
||||
|
||||
return true;
|
||||
return $this->outStream->write($frame);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,7 +273,10 @@ class WebSocketConnection implements WebSocketInterface
|
||||
$this->emit('close', []);
|
||||
}
|
||||
|
||||
public function closeWithReason(string $reason, int $code=1000)
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function closeWithReason(string $reason, int $code=1000): void
|
||||
{
|
||||
$payload = chr(($code >> 8) & 0xFF) . chr($code & 0xFF) . $reason;
|
||||
$this->send(self::OP_CLOSE, $payload);
|
||||
|
Reference in New Issue
Block a user