Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 9 files). Show all
Unified · Split
| @@ -190,6 +190,11 @@ MetavoxelClient::MetavoxelClient(const HifiSockAddr& address) : · 189 unmodified lines | ||
| 190 | 190 | |
| 191 | 191 | connect(&_sequencer, SIGNAL(readyToWrite(const QByteArray&)), SLOT(sendData(const QByteArray&))); |
| 192 | 192 | connect(&_sequencer, SIGNAL(readyToRead(Bitstream&)), SLOT(readPacket(Bitstream&))); |
| 193 | + connect(&_sequencer, SIGNAL(receiveAcknowledged(int)), SLOT(clearReceiveRecordsBefore(int))); | |
| 194 | + | |
| 195 | + // insert the baseline receive record | |
| 196 | + ReceiveRecord record = { 0 }; | |
| 197 | + _receiveRecords.append(record); | |
| 193 | 198 | } |
| 194 | 199 | |
| 195 | 200 | void MetavoxelClient::simulate(float deltaTime) { |
| @@ -212,5 +217,27 @@ void MetavoxelClient::sendData(const QByteArray& data) { · 16 unmodified lines | ||
| 212 | 217 | } |
| 213 | 218 | |
| 214 | 219 | void MetavoxelClient::readPacket(Bitstream& in) { |
| 215 | − qDebug("got packet from server!\n"); | |
| 220 | + QVariant message; | |
| 221 | + in >> message; | |
| 222 | + handleMessage(message); | |
| 223 | + | |
| 224 | + // record the receipt | |
| 225 | + ReceiveRecord record = { _sequencer.getIncomingPacketNumber() }; | |
| 226 | + _receiveRecords.append(record); | |
| 227 | +} | |
| 228 | + | |
| 229 | +void MetavoxelClient::clearReceiveRecordsBefore(int index) { | |
| 230 | + _receiveRecords.erase(_receiveRecords.begin(), _receiveRecords.begin() + index + 1); | |
| 231 | +} | |
| 232 | + | |
| 233 | +void MetavoxelClient::handleMessage(const QVariant& message) { | |
| 234 | + int userType = message.userType(); | |
| 235 | + if (userType == MetavoxelDeltaMessage::Type) { | |
| 236 | + | |
| 237 | + | |
| 238 | + } else if (userType == QMetaType::QVariantList) { | |
| 239 | + foreach (const QVariant& element, message.toList()) { | |
| 240 | + handleMessage(element); | |
| 241 | + } | |
| 242 | + } | |
| 216 | 243 | } |