fix packet sending from VoxelScriptingInterface

This commit is contained in:
Stephen Birarda 2013-12-03 12:09:47 -08:00
parent 182c69c7b8
commit 5143c68b91
5 changed files with 13 additions and 17 deletions

View file

@ -127,9 +127,7 @@ void Agent::run() {
QCoreApplication::processEvents(); QCoreApplication::processEvents();
if (_voxelScriptingInterface.getVoxelPacketSender()->voxelServersExist()) { if (_voxelScriptingInterface.getVoxelPacketSender()->voxelServersExist()) {
timeval thisSend = {};
gettimeofday(&thisSend, NULL);
// allow the scripter's call back to setup visual data // allow the scripter's call back to setup visual data
emit willSendVisualDataCallback(); emit willSendVisualDataCallback();

View file

@ -74,7 +74,12 @@ void AssignmentClient::readPendingDatagrams() {
senderSockAddr.getPortPointer())) senderSockAddr.getPortPointer()))
&& packetVersionMatch(packetData)) { && packetVersionMatch(packetData)) {
if (packetData[0] == PACKET_TYPE_DEPLOY_ASSIGNMENT || packetData[0] == PACKET_TYPE_CREATE_ASSIGNMENT) { if (_currentAssignment) {
// have the threaded current assignment handle this datagram
QMetaObject::invokeMethod(_currentAssignment, "processDatagram", Qt::QueuedConnection,
Q_ARG(const QByteArray&, QByteArray((char*) packetData, receivedBytes)),
Q_ARG(const HifiSockAddr&, senderSockAddr));
} else if (packetData[0] == PACKET_TYPE_DEPLOY_ASSIGNMENT || packetData[0] == PACKET_TYPE_CREATE_ASSIGNMENT) {
if (_currentAssignment) { if (_currentAssignment) {
qDebug() << "Dropping received assignment since we are currently running one.\n"; qDebug() << "Dropping received assignment since we are currently running one.\n";
@ -110,11 +115,6 @@ void AssignmentClient::readPendingDatagrams() {
qDebug("Received a bad destination socket for assignment.\n"); qDebug("Received a bad destination socket for assignment.\n");
} }
} }
} else if (_currentAssignment) {
// have the threaded current assignment handle this datagram
QMetaObject::invokeMethod(_currentAssignment, "processDatagram", Qt::QueuedConnection,
Q_ARG(const QByteArray&, QByteArray((char*) packetData, receivedBytes)),
Q_ARG(const HifiSockAddr&, senderSockAddr));
} else { } else {
// have the NodeList attempt to handle it // have the NodeList attempt to handle it
nodeList->processNodeData(senderSockAddr, packetData, receivedBytes); nodeList->processNodeData(senderSockAddr, packetData, receivedBytes);

View file

@ -27,13 +27,11 @@ void VoxelScriptingInterface::queueVoxelAdd(float x, float y, float z, float sca
void VoxelScriptingInterface::queueDestructiveVoxelAdd(float x, float y, float z, float scale, void VoxelScriptingInterface::queueDestructiveVoxelAdd(float x, float y, float z, float scale,
uchar red, uchar green, uchar blue) { uchar red, uchar green, uchar blue) {
// // setup a VoxelDetail struct with the data // setup a VoxelDetail struct with the data
// VoxelDetail addVoxelDetail = {x, y, z, scale, red, green, blue}; VoxelDetail addVoxelDetail = {x, y, z, scale, red, green, blue};
//
// // queue the destructive add
// queueVoxelAdd(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, addVoxelDetail);
_voxelTree.createVoxel(x, y, z, scale, red, green, blue); // queue the destructive add
queueVoxelAdd(PACKET_TYPE_SET_VOXEL_DESTRUCTIVE, addVoxelDetail);
} }
void VoxelScriptingInterface::queueVoxelDelete(float x, float y, float z, float scale) { void VoxelScriptingInterface::queueVoxelDelete(float x, float y, float z, float scale) {

View file

@ -523,13 +523,12 @@ void VoxelServer::processDatagram(const QByteArray& dataByteArray, const HifiSoc
uint64_t sentAt = (*((uint64_t*)(dataByteArray.data() + numBytesPacketHeader + sizeof(sequence)))); uint64_t sentAt = (*((uint64_t*)(dataByteArray.data() + numBytesPacketHeader + sizeof(sequence))));
uint64_t arrivedAt = usecTimestampNow(); uint64_t arrivedAt = usecTimestampNow();
uint64_t transitTime = arrivedAt - sentAt; uint64_t transitTime = arrivedAt - sentAt;
if (wantShowAnimationDebug() || wantsDebugVoxelReceiving()) { if (true) {
printf("RECEIVE THREAD: got %s - command from client receivedBytes=%d sequence=%d transitTime=%llu usecs\n", printf("RECEIVE THREAD: got %s - command from client receivedBytes=%d sequence=%d transitTime=%llu usecs\n",
messageName, messageName,
dataByteArray.size(), sequence, transitTime); dataByteArray.size(), sequence, transitTime);
} }
} }
_voxelServerPacketProcessor->queueReceivedPacket(senderSockAddr, _voxelServerPacketProcessor->queueReceivedPacket(senderSockAddr,
(unsigned char*) dataByteArray.data(), dataByteArray.size()); (unsigned char*) dataByteArray.data(), dataByteArray.size());
} else { } else {

View file

@ -313,6 +313,7 @@ void VoxelEditPacketSender::releaseQueuedMessages() {
void VoxelEditPacketSender::releaseQueuedPacket(EditPacketBuffer& packetBuffer) { void VoxelEditPacketSender::releaseQueuedPacket(EditPacketBuffer& packetBuffer) {
if (packetBuffer._currentSize > 0 && packetBuffer._currentType != PACKET_TYPE_UNKNOWN) { if (packetBuffer._currentSize > 0 && packetBuffer._currentType != PACKET_TYPE_UNKNOWN) {
qDebug() << "queueing packet to node\n";
queuePacketToNode(packetBuffer._nodeUUID, &packetBuffer._currentBuffer[0], packetBuffer._currentSize); queuePacketToNode(packetBuffer._nodeUUID, &packetBuffer._currentBuffer[0], packetBuffer._currentSize);
} }
packetBuffer._currentSize = 0; packetBuffer._currentSize = 0;