void VoxelEditPacketSender::sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail) { // allows app to disable sending if for example voxels have been disabled if (!_shouldSend) { return; // bail early } unsigned char* bufferOut; int sizeOut; // This encodes the voxel edit message into a buffer... if (createVoxelEditMessage(type, 0, 1, &detail, bufferOut, sizeOut)){ // If we don't have voxel jurisdictions, then we will simply queue up these packets and wait till we have // jurisdictions for processing if (!voxelServersExist()) { // If we're asked to save messages while waiting for voxel servers to arrive, then do so... if (_maxPendingMessages > 0) { EditPacketBuffer* packet = new EditPacketBuffer(type, bufferOut, sizeOut); _preServerSingleMessagePackets.push_back(packet); // if we've saved MORE than out max, then clear out the oldest packet... int allPendingMessages = _preServerSingleMessagePackets.size() + _preServerPackets.size(); if (allPendingMessages > _maxPendingMessages) { EditPacketBuffer* packet = _preServerSingleMessagePackets.front(); delete packet; _preServerSingleMessagePackets.erase(_preServerSingleMessagePackets.begin()); } } return; // bail early } else { queuePacketToNodes(bufferOut, sizeOut); } // either way, clean up the created buffer delete[] bufferOut; } }
void OctreeEditPacketSender::processPreServerExistsPackets() { assert(serversExist()); // we should only be here if we have jurisdictions // First send out all the single message packets... _pendingPacketsLock.lock(); while (!_preServerSingleMessagePackets.empty()) { EditPacketBuffer* packet = _preServerSingleMessagePackets.front(); queuePacketToNodes(&packet->_currentBuffer[0], packet->_currentSize); delete packet; _preServerSingleMessagePackets.erase(_preServerSingleMessagePackets.begin()); } // Then "process" all the packable messages... while (!_preServerPackets.empty()) { EditPacketBuffer* packet = _preServerPackets.front(); queueOctreeEditMessage(packet->_currentType, &packet->_currentBuffer[0], packet->_currentSize); delete packet; _preServerPackets.erase(_preServerPackets.begin()); } _pendingPacketsLock.unlock(); // if while waiting for the jurisdictions the caller called releaseQueuedMessages() // then we want to honor that request now. if (_releaseQueuedMessagesPending) { releaseQueuedMessages(); _releaseQueuedMessagesPending = false; } }
void VoxelEditPacketSender::sendVoxelEditMessage(PacketType type, const VoxelDetail& detail) { // allows app to disable sending if for example voxels have been disabled if (!_shouldSend) { return; // bail early } unsigned char* bufferOut; int sizeOut; // This encodes the voxel edit message into a buffer... if (createVoxelEditMessage(type, 0, 1, &detail, bufferOut, sizeOut)){ // If we don't have voxel jurisdictions, then we will simply queue up these packets and wait till we have // jurisdictions for processing if (!voxelServersExist()) { queuePendingPacketToNodes(type, bufferOut, sizeOut, satoshiCostForMessage(detail)); } else { queuePacketToNodes(bufferOut, sizeOut, satoshiCostForMessage(detail)); } // either way, clean up the created buffer delete[] bufferOut; } }