Merge branch 'atp' of https://github.com/birarda/hifi into protocol

This commit is contained in:
Atlante45 2015-07-14 19:18:36 -07:00
commit e3b7b20f36
3 changed files with 13 additions and 8 deletions

View file

@ -288,7 +288,6 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket");
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
packetReceiver.registerListener(PacketType::ICEPingReply, this, "processICEPingReplyPacket");
packetReceiver.registerListener(PacketType::ICEServerPeerInformation, this, "processICEPeerInformationPacket");
// add whatever static assignments that have been parsed to the queue
addStaticAssignmentsToQueue();
@ -580,6 +579,11 @@ void DomainServer::processConnectRequestPacket(QSharedPointer<NLPacket> packet)
NodeType_t nodeType;
HifiSockAddr publicSockAddr, localSockAddr;
if (packet->getSizeUsed() == 0) {
// TODO: We know what size the connect packet should be (minimally) - check for that here
return;
}
QDataStream packetStream(packet.data());
QUuid connectUUID;

View file

@ -512,7 +512,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
}
void NodeList::sendAssignment(Assignment& assignment) {
PacketType::Value assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
? PacketType::CreateAssignment
: PacketType::RequestAssignment;
@ -520,7 +520,6 @@ void NodeList::sendAssignment(Assignment& assignment) {
auto assignmentPacket = NLPacket::create(assignmentPacketType);
QDataStream packetStream(assignmentPacket.get());
packetStream << assignment;
// TODO: should this be a non sourced packet?

View file

@ -61,17 +61,18 @@ qint64 Packet::localHeaderSize() const {
Packet::Packet(PacketType::Value type, qint64 size) :
_type(type),
_version(0),
_packetSize(localHeaderSize(_type) + size),
_packet(new char(_packetSize)),
_payloadStart(_packet.get() + localHeaderSize(_type)),
_capacity(size)
_version(0)
{
auto maxPayload = maxPayloadSize(type);
if (size == -1) {
// default size of -1, means biggest packet possible
size = maxPayload;
}
_packetSize = localHeaderSize(type) + size;
_packet.reset(new char(_packetSize));
_capacity = size;
_payloadStart = _packet.get() + (_packetSize - _capacity);
// Sanity check
Q_ASSERT(size >= 0 || size < maxPayload);
@ -191,6 +192,7 @@ void Packet::writeSequenceNumber(SequenceNumber seqNum) {
static const qint64 PACKET_WRITE_ERROR = -1;
qint64 Packet::writeData(const char* data, qint64 maxSize) {
// make sure we have the space required to write this block
if (maxSize <= bytesAvailableForWrite()) {
qint64 currentPos = pos();