From 3df07d344f8dd5e2b4d140f2efb9d83372b6d17f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 25 Oct 2013 11:39:21 -0700 Subject: [PATCH 1/2] have assignment client pay attention to jurisdictions --- assignment-client/src/Agent.cpp | 8 +++++++- assignment-client/src/voxels/VoxelScriptingInterface.cpp | 7 ++++++- assignment-client/src/voxels/VoxelScriptingInterface.h | 5 +++++ libraries/shared/src/PacketSender.cpp | 4 +++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index baf04372d2..ef6a2caa35 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -201,7 +201,13 @@ void Agent::run() { while (NodeList::getInstance()->getNodeSocket()->receive((sockaddr*) &senderAddress, receivedData, &receivedBytes) && packetVersionMatch(receivedData)) { - NodeList::getInstance()->processNodeData((sockaddr*) &senderAddress, receivedData, receivedBytes); + if (receivedData[0] == PACKET_TYPE_VOXEL_JURISDICTION) { + voxelScripter.getJurisdictionListener()->queueReceivedPacket((sockaddr&) senderAddress, + receivedData, + receivedBytes); + } else { + NodeList::getInstance()->processNodeData((sockaddr*) &senderAddress, receivedData, receivedBytes); + } } } diff --git a/assignment-client/src/voxels/VoxelScriptingInterface.cpp b/assignment-client/src/voxels/VoxelScriptingInterface.cpp index e94f87264a..5b1a296aa7 100644 --- a/assignment-client/src/voxels/VoxelScriptingInterface.cpp +++ b/assignment-client/src/voxels/VoxelScriptingInterface.cpp @@ -8,6 +8,11 @@ #include "VoxelScriptingInterface.h" +VoxelScriptingInterface::VoxelScriptingInterface() { + _jurisdictionListener.initialize(true); + _voxelPacketSender.setVoxelServerJurisdictions(_jurisdictionListener.getJurisdictions()); +} + void VoxelScriptingInterface::queueVoxelAdd(PACKET_TYPE addPacketType, VoxelDetail& addVoxelDetails) { _voxelPacketSender.queueVoxelEditMessages(addPacketType, 1, &addVoxelDetails); } @@ -35,4 +40,4 @@ void VoxelScriptingInterface::queueVoxelDelete(float x, float y, float z, float VoxelDetail deleteVoxelDetail = {x, y, z, scale, 0, 0, 0}; _voxelPacketSender.queueVoxelEditMessages(PACKET_TYPE_ERASE_VOXEL, 1, &deleteVoxelDetail); -} +} \ No newline at end of file diff --git a/assignment-client/src/voxels/VoxelScriptingInterface.h b/assignment-client/src/voxels/VoxelScriptingInterface.h index ac1de6928d..a2c18b8018 100644 --- a/assignment-client/src/voxels/VoxelScriptingInterface.h +++ b/assignment-client/src/voxels/VoxelScriptingInterface.h @@ -11,13 +11,17 @@ #include +#include #include /// handles scripting of voxel commands from JS passed to assigned clients class VoxelScriptingInterface : public QObject { Q_OBJECT public: + VoxelScriptingInterface(); + VoxelEditPacketSender* getVoxelPacketSender() { return &_voxelPacketSender; } + JurisdictionListener* getJurisdictionListener() { return &_jurisdictionListener; } public slots: /// queues the creation of a voxel which will be sent by calling process on the PacketSender /// \param x the x-coordinate of the voxel (in VS space) @@ -48,6 +52,7 @@ public slots: private: /// attached VoxelEditPacketSender that handles queuing and sending of packets to VS VoxelEditPacketSender _voxelPacketSender; + JurisdictionListener _jurisdictionListener; void queueVoxelAdd(PACKET_TYPE addPacketType, VoxelDetail& addVoxelDetails); }; diff --git a/libraries/shared/src/PacketSender.cpp b/libraries/shared/src/PacketSender.cpp index ecd92a1f05..0b41a34caf 100644 --- a/libraries/shared/src/PacketSender.cpp +++ b/libraries/shared/src/PacketSender.cpp @@ -74,8 +74,10 @@ bool PacketSender::process() { // we can determine how many packets we need to send per call to achieve our desired // packets per second send rate. int callsPerSecond = USECS_PER_SECOND / averageCallTime; + // make sure our number of calls per second doesn't cause a divide by zero - glm::clamp(callsPerSecond, 1, _packetsPerSecond); + callsPerSecond = glm::clamp(callsPerSecond, 1, _packetsPerSecond); + packetsPerCall = ceil(_packetsPerSecond / callsPerSecond); // send at least one packet per call, if we have it From d97292a4f17542014796bb2d36403fb98ce3b733 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 25 Oct 2013 14:07:50 -0700 Subject: [PATCH 2/2] run the silent node removal thread in the agent --- assignment-client/src/Agent.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index ef6a2caa35..1a63d2c4d5 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -143,6 +143,8 @@ void Agent::run() { int thisFrame = 0; + NodeList::getInstance()->startSilentNodeRemovalThread(); + while (!_shouldStop) { // if we're not hearing from the domain-server we should stop running @@ -210,6 +212,8 @@ void Agent::run() { } } } + + NodeList::getInstance()->stopSilentNodeRemovalThread(); } else { // error in curl_easy_perform