Working with QDataStream and QTcpSocket
The missing piece of the SDK is MesssageUtils
. It deserves a dedicated section because it covers two major topics: serialization and QDataStream
transactions.
We will start with the serialization. We already know that Message
stores only an opaque QByteArray
data member. As a consequence, the desired data has to be serialized as a QByteArray
before being passed to Message
.
If we take the example of a JobRequest
object, it is not directly sent. We first put in in a generic Message
object with the appropriate Message
type. The following diagram summarizes the sequence of actions to be done:
The JobRequest
object ...
Get Mastering Qt 5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.