public function sendData(string $data, int $type = Protocol::TYPE_TEXT, $masked = true)
    {
        if (!$this->isConnected()) {
            return false;
        }

        $payload = $this->protocol->getPayload();

        $payload->encode(
            $data,
            $type,
            $masked
        );

        return $payload->sendToSocket($this->socket);
    }