mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge branch 'protocol' of https://github.com/huffman/hifi into atp
This commit is contained in:
commit
59e14dfd65
2 changed files with 10 additions and 0 deletions
|
@ -210,6 +210,13 @@ void Packet::writeSequenceNumber(SequenceNumber seqNum) {
|
||||||
&seqNum, sizeof(seqNum));
|
&seqNum, sizeof(seqNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray Packet::read(qint64 maxSize) {
|
||||||
|
qint64 sizeToRead = std::min(size() - pos(), maxSize);
|
||||||
|
QByteArray data { QByteArray::fromRawData(getPayload() + pos(), sizeToRead) };
|
||||||
|
seek(pos() + sizeToRead);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
qint64 Packet::writeData(const char* data, qint64 maxSize) {
|
qint64 Packet::writeData(const char* data, qint64 maxSize) {
|
||||||
|
|
||||||
// make sure we have the space required to write this block
|
// make sure we have the space required to write this block
|
||||||
|
|
|
@ -79,6 +79,9 @@ public:
|
||||||
virtual bool reset();
|
virtual bool reset();
|
||||||
virtual qint64 size() const { return _payloadCapacity; }
|
virtual qint64 size() const { return _payloadCapacity; }
|
||||||
|
|
||||||
|
using QIODevice::read;
|
||||||
|
QByteArray read(qint64 maxSize);
|
||||||
|
|
||||||
template<typename T> qint64 peekPrimitive(T* data);
|
template<typename T> qint64 peekPrimitive(T* data);
|
||||||
template<typename T> qint64 readPrimitive(T* data);
|
template<typename T> qint64 readPrimitive(T* data);
|
||||||
template<typename T> qint64 writePrimitive(const T& data);
|
template<typename T> qint64 writePrimitive(const T& data);
|
||||||
|
|
Loading…
Reference in a new issue