|
1 | 1 | #include "../WebSocket.h"
|
2 | 2 | #include <QFile>
|
3 | 3 | #include <QHostAddress>
|
4 |
| -#include <QRegExp> |
| 4 | +#include <QRegularExpression> |
5 | 5 | #include <QTcpServer>
|
6 | 6 | #include <QSslCertificate>
|
7 | 7 | #include <QSslConfiguration>
|
@@ -61,13 +61,14 @@ int main(int argc, char *argv[])
|
61 | 61 | // stand alone test encoding / decoding
|
62 | 62 | std::cout << "Enter text:\n";
|
63 | 63 | std::array<char, 65536> linebuf;
|
64 |
| - const QRegExp hexRE("^[0-9a-fA-F]+$"); |
| 64 | + const QRegularExpression hexRE("^[0-9a-fA-F]+$"); |
65 | 65 | while ( std::cin.getline(linebuf.data(), linebuf.size()) ) {
|
66 | 66 | QByteArray b = QByteArray(linebuf.data()).trimmed();
|
67 | 67 | QByteArray frameData;
|
68 | 68 |
|
69 | 69 | try {
|
70 |
| - if (hexRE.exactMatch(b)) { |
| 70 | + if (hexRE.match(b).hasMatch()) { |
| 71 | + // input was some hex encoded data |
71 | 72 | frameData = QByteArray::fromHex(b);
|
72 | 73 | } else {
|
73 | 74 | frameData = WebSocket::Ser::wrapText(b, true, 260);
|
@@ -300,7 +301,7 @@ int main(int argc, char *argv[])
|
300 | 301 | qDebug("Got text frame [%s], echoing back", f.payload.constData());
|
301 | 302 | sock->sendText(QByteArray("ECHO ") + f.payload);
|
302 | 303 | } else {
|
303 |
| - qDebug("Got data frame [%d bytes], echoing back", f.payload.size()); |
| 304 | + qDebug("Got data frame [%d bytes], echoing back", int(f.payload.size())); |
304 | 305 | sock->sendBinary(f.payload);
|
305 | 306 | }
|
306 | 307 | }
|
|
0 commit comments