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;
    }
}
Example #2
0
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;
    }
}