for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Helix\Socket\WebSocket;
class MessageHandler {
/**
* @var WebSocketClient
*/
protected $client;
* @param WebSocketClient $client
public function __construct (WebSocketClient $client) {
$this->client = $client;
}
* @param string $binary
public function onBinary (string $binary): void {
unset($binary);
throw new WebSocketError(Frame::CLOSE_UNHANDLED_DATA, "I don't handle binary data.");
* @param string $text
public function onText (string $text): void {
$this->onText_CheckUtf8($text);
throw new WebSocketError(Frame::CLOSE_UNHANDLED_DATA, "I don't handle text.");
* Throws if the payload isn't UTF-8.
*
protected function onText_CheckUtf8 (string $text): void {
if (!mb_detect_encoding($text, 'UTF-8', true)) {
throw new WebSocketError(Frame::CLOSE_BAD_DATA, "Received TEXT is not UTF-8.");