QMaskGenerator Class
The QMaskGenerator class is the base of generators of the masking keys that WebSocket clients use. More…
| Header | #include <QMaskGenerator> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::WebSockets) |
| Module | Nt WebSockets C++ Classes |
| Since | 5.3 |
| Inherits | QObject |
List of all members, including inherited members
Public Functions
| QMaskGenerator(QObject *parent = nullptr) | |
| ~QMaskGenerator() | |
| virtual bool | seed() |
| virtual quint32 | nextMask() |
Detailed Description
A WebSocket client masks each frame it sends with a 32-bit key, so that a script cannot place chosen bytes on the wire and confuse proxies. QWebSocket uses the system's random number generator by default. A subclass can replace it, for example to make tests repeatable; pass it to QWebSocket::setMaskGenerator().
See also QWebSocket::setMaskGenerator().
Differences from Qt
None.
Member Function Documentation
QMaskGenerator::QMaskGenerator(QObject *parent = nullptr)
Constructs a mask generator with the given parent.
QMaskGenerator::~QMaskGenerator()
Destroys the mask generator.
quint32 QMaskGenerator::nextMask()
Returns the next 32-bit masking key. Keys must be unpredictable, so that a script cannot choose the bytes that appear on the wire.
See also seed().
bool QMaskGenerator::seed()
Prepares the generator for use, for example by seeding a random number generator. Returns true on success; a socket does not use a generator whose seed() fails.
See also nextMask().