6.0.0-rc4Source

QMaskGenerator Class

The QMaskGenerator class is the base of generators of the masking keys that WebSocket clients use. More…

Header#include <QMaskGenerator>
CMaketarget_link_libraries(app PRIVATE Nt::WebSockets)
ModuleNt WebSockets C++ Classes
Since5.3
InheritsQObject

List of all members, including inherited members

Public Functions

QMaskGenerator(QObject *parent = nullptr)
~QMaskGenerator()
virtual boolseed()
virtual quint32nextMask()

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

[explicit] QMaskGenerator::QMaskGenerator(QObject *parent = nullptr)

Constructs a mask generator with the given parent.

[override] QMaskGenerator::~QMaskGenerator()

Destroys the mask generator.

[virtual] 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().

[virtual] 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().