mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
keep track of max written in PacketPayload
This commit is contained in:
parent
b660c80988
commit
1867f259d6
2 changed files with 5 additions and 1 deletions
|
@ -31,9 +31,12 @@ qint64 PacketPayload::writeData(const char* data, qint64 maxSize) {
|
||||||
// good to go - write the data
|
// good to go - write the data
|
||||||
memcpy(_data + currentPos, src, srcBytes);
|
memcpy(_data + currentPos, src, srcBytes);
|
||||||
|
|
||||||
// should this cause us to push our index (is this the farthest we've written in data)?
|
// seek to the new position based on where our write just finished
|
||||||
seek(currentPos + srcBytes);
|
seek(currentPos + srcBytes);
|
||||||
|
|
||||||
|
// keep track of _maxWritten so we can just write the actual data when packet is about to be sent
|
||||||
|
_maxWritten = std::max(pos() + 1, _maxWritten);
|
||||||
|
|
||||||
// return the number of bytes written
|
// return the number of bytes written
|
||||||
return srcBytes;
|
return srcBytes;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,6 +30,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
char* _data;
|
char* _data;
|
||||||
qint64 _size = 0;
|
qint64 _size = 0;
|
||||||
|
qint64 _maxWritten = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_PacketByteArray_h
|
#endif // hifi_PacketByteArray_h
|
||||||
|
|
Loading…
Reference in a new issue