mirror of
https://github.com/overte-org/overte.git
synced 2025-08-13 16:03:52 +02:00
Merge branch 'atp' of https://github.com/birarda/hifi into protocol
This commit is contained in:
commit
6577845d3f
3 changed files with 18 additions and 1 deletions
|
@ -167,6 +167,9 @@ void Connection::processControl(unique_ptr<ControlPacket> controlPacket) {
|
|||
break;
|
||||
}
|
||||
case ControlPacket::ACK2: {
|
||||
// change the type of the packet to an ACK2 and send it back
|
||||
controlPacket->setType(ControlPacket::ACK2);
|
||||
_sendQueue->sendPacket(*controlPacket);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -94,12 +94,24 @@ ControlPacket& ControlPacket::operator=(ControlPacket&& other) {
|
|||
|
||||
static const uint32_t CONTROL_BIT_MASK = 1 << (sizeof(ControlPacket::ControlBitAndType) - 1);
|
||||
|
||||
void ControlPacket::setType(udt::ControlPacket::Type type) {
|
||||
_type = type;
|
||||
|
||||
writeType();
|
||||
}
|
||||
|
||||
void ControlPacket::writeControlBitAndType() {
|
||||
ControlBitAndType* bitAndType = reinterpret_cast<ControlBitAndType*>(_packet.get());
|
||||
|
||||
// write the control bit by OR'ing the current value with the CONTROL_BIT_MASK
|
||||
*bitAndType = (*bitAndType | CONTROL_BIT_MASK);
|
||||
|
||||
// write the type by OR'ing the type with the current value & CONTROL_BIT_MASK
|
||||
writeType();
|
||||
}
|
||||
|
||||
void ControlPacket::writeType() {
|
||||
ControlBitAndType* bitAndType = reinterpret_cast<ControlBitAndType*>(_packet.get());
|
||||
|
||||
// write the type by OR'ing the new type with the current value & CONTROL_BIT_MASK
|
||||
*bitAndType = (*bitAndType & CONTROL_BIT_MASK) | (_type << sizeof((ControlPacket::Type) - 1));
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
virtual qint64 totalHeadersSize() const; // Cumulated size of all the headers
|
||||
|
||||
Type getType() const { return _type; }
|
||||
void setType(Type type);
|
||||
|
||||
private:
|
||||
ControlPacket(Type type);
|
||||
|
@ -54,6 +55,7 @@ private:
|
|||
|
||||
// Header writers
|
||||
void writeControlBitAndType();
|
||||
void writeType();
|
||||
|
||||
Type _type;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue