Sonic::Ipc::FrameReader Class
Splits a byte stream into frames. More...
- Header:
#include <Sonic/Ipc/FrameReader> - CMake:
find_package(SonicIpc REQUIRED)
target_link_libraries(mytarget PRIVATE Sonic::Ipc)
List of all members, including inherited members
Public Types
Public Functions
- FrameReader(quint16 expectedProtocol, qint64 maxPayload = defaultMaxPayload)
- Sonic::Ipc::FrameReader::Error error() const
- QString errorString() const
- void feed(QByteArrayView data)
- std::optional<Sonic::Ipc::Frame> next()
- quint16 peerProtocolVersion() const
Detailed Description
The payload length is checked as soon as the header is complete, before any payload is buffered. After an error the reader stays in error; the caller closes the connection.
Member Type Documentation
enum FrameReader::Error
What the reader rejected.
| Constant | Value | Description |
|---|---|---|
Sonic::Ipc::FrameReader::Error::None |
0 |
No error. |
Sonic::Ipc::FrameReader::Error::BadMagic |
1 |
The data doesn't start with frameMagic: not a Sonic IPC peer. |
Sonic::Ipc::FrameReader::Error::BadFormatVersion |
2 |
An unsupported frame format. |
Sonic::Ipc::FrameReader::Error::ProtocolMismatch |
3 |
The peer speaks another application protocol version. |
Sonic::Ipc::FrameReader::Error::TooLarge |
4 |
The payload is larger than the limit. |
Sonic::Ipc::FrameReader::Error::BadChecksum |
5 |
The payload doesn't match its CRC-32. |
Member Function Documentation
[explicit] FrameReader::FrameReader(quint16 expectedProtocol, qint64 maxPayload = defaultMaxPayload)
Creates a reader for application protocol expectedProtocol that rejects payloads larger than maxPayload bytes.
Sonic::Ipc::FrameReader::Error FrameReader::error() const
What the reader rejected, or Error::None.
QString FrameReader::errorString() const
A description of error().
void FrameReader::feed(QByteArrayView data)
Appends data received from the stream.
std::optional<Sonic::Ipc::Frame> FrameReader::next()
The next complete frame; nothing while a frame is incomplete or after an error.
quint16 FrameReader::peerProtocolVersion() const
The protocol version in the last header read; names the peer's version after ProtocolMismatch.