mirror of
https://github.com/overte-org/overte.git
synced 2025-06-27 12:29:36 +02:00
hook VS to new QCA infrastructure
This commit is contained in:
parent
ed854dcb7b
commit
6f7e16dc22
7 changed files with 99 additions and 99 deletions
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include <AudioRingBuffer.h>
|
#include <AudioRingBuffer.h>
|
||||||
|
|
||||||
#include "../ThreadedAssignment.h"
|
#include <ThreadedAssignment.h>
|
||||||
|
|
||||||
class PositionalAudioRingBuffer;
|
class PositionalAudioRingBuffer;
|
||||||
class AvatarAudioRingBuffer;
|
class AvatarAudioRingBuffer;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __hifi__AvatarMixer__
|
#ifndef __hifi__AvatarMixer__
|
||||||
#define __hifi__AvatarMixer__
|
#define __hifi__AvatarMixer__
|
||||||
|
|
||||||
#include "../ThreadedAssignment.h"
|
#include <ThreadedAssignment.h>
|
||||||
|
|
||||||
/// Handles assignments of type AvatarMixer - distribution of avatar data to various clients
|
/// Handles assignments of type AvatarMixer - distribution of avatar data to various clients
|
||||||
class AvatarMixer : public ThreadedAssignment {
|
class AvatarMixer : public ThreadedAssignment {
|
||||||
|
|
|
@ -725,7 +725,6 @@ unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataByt
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::pingInactiveNodes() {
|
void NodeList::pingInactiveNodes() {
|
||||||
qDebug() << "Pinging inactive nodes\n";
|
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
for(NodeList::iterator node = begin(); node != end(); node++) {
|
||||||
if (!node->getActiveSocket()) {
|
if (!node->getActiveSocket()) {
|
||||||
// we don't have an active link to this node, ping it to set that up
|
// we don't have an active link to this node, ping it to set that up
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __hifi__ThreadedAssignment__
|
#ifndef __hifi__ThreadedAssignment__
|
||||||
#define __hifi__ThreadedAssignment__
|
#define __hifi__ThreadedAssignment__
|
||||||
|
|
||||||
#include <Assignment.h>
|
#include "Assignment.h"
|
||||||
|
|
||||||
class ThreadedAssignment : public Assignment {
|
class ThreadedAssignment : public Assignment {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
|
@ -53,8 +54,10 @@ void attachVoxelNodeDataToNode(Node* newNode) {
|
||||||
|
|
||||||
VoxelServer* VoxelServer::_theInstance = NULL;
|
VoxelServer* VoxelServer::_theInstance = NULL;
|
||||||
|
|
||||||
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes),
|
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) :
|
||||||
_serverTree(true) {
|
ThreadedAssignment(dataBuffer, numBytes),
|
||||||
|
_serverTree(true)
|
||||||
|
{
|
||||||
_argc = 0;
|
_argc = 0;
|
||||||
_argv = NULL;
|
_argv = NULL;
|
||||||
|
|
||||||
|
@ -466,6 +469,77 @@ void VoxelServer::parsePayload() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxelServer::processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr) {
|
||||||
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
|
int numBytesPacketHeader = numBytesForPacketHeader((unsigned char*)dataByteArray.data());
|
||||||
|
|
||||||
|
if (dataByteArray.data()[0] == PACKET_TYPE_VOXEL_QUERY) {
|
||||||
|
// If we got a PACKET_TYPE_VOXEL_QUERY, then we're talking to an NODE_TYPE_AVATAR, and we
|
||||||
|
// need to make sure we have it in our nodeList.
|
||||||
|
QUuid nodeUUID = QUuid::fromRfc4122(dataByteArray.mid(numBytesForPacketHeader((unsigned char*) dataByteArray.data()),
|
||||||
|
NUM_BYTES_RFC4122_UUID));
|
||||||
|
|
||||||
|
Node* node = nodeList->nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
nodeList->updateNodeWithData(node, senderSockAddr, (unsigned char*) dataByteArray.data(), dataByteArray.size());
|
||||||
|
if (!node->getActiveSocket()) {
|
||||||
|
// we don't have an active socket for this node, but they're talking to us
|
||||||
|
// this means they've heard from us and can reply, let's assume public is active
|
||||||
|
node->activatePublicSocket();
|
||||||
|
}
|
||||||
|
VoxelNodeData* nodeData = (VoxelNodeData*) node->getLinkedData();
|
||||||
|
if (nodeData && !nodeData->isVoxelSendThreadInitalized()) {
|
||||||
|
nodeData->initializeVoxelSendThread(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (dataByteArray.data()[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
||||||
|
if (_jurisdictionSender) {
|
||||||
|
_jurisdictionSender->queueReceivedPacket(senderSockAddr,
|
||||||
|
(unsigned char*) dataByteArray.data(), dataByteArray.size());
|
||||||
|
}
|
||||||
|
} else if (_voxelServerPacketProcessor &&
|
||||||
|
(dataByteArray.data()[0] == PACKET_TYPE_SET_VOXEL
|
||||||
|
|| dataByteArray.data()[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE
|
||||||
|
|| dataByteArray.data()[0] == PACKET_TYPE_ERASE_VOXEL
|
||||||
|
|| dataByteArray.data()[0] == PACKET_TYPE_Z_COMMAND)) {
|
||||||
|
|
||||||
|
const char* messageName;
|
||||||
|
switch (dataByteArray.data()[0]) {
|
||||||
|
case PACKET_TYPE_SET_VOXEL:
|
||||||
|
messageName = "PACKET_TYPE_SET_VOXEL";
|
||||||
|
break;
|
||||||
|
case PACKET_TYPE_SET_VOXEL_DESTRUCTIVE:
|
||||||
|
messageName = "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE";
|
||||||
|
break;
|
||||||
|
case PACKET_TYPE_ERASE_VOXEL:
|
||||||
|
messageName = "PACKET_TYPE_ERASE_VOXEL";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataByteArray.data()[0] != PACKET_TYPE_Z_COMMAND) {
|
||||||
|
unsigned short int sequence = (*((unsigned short int*)(dataByteArray.data() + numBytesPacketHeader)));
|
||||||
|
uint64_t sentAt = (*((uint64_t*)(dataByteArray.data() + numBytesPacketHeader + sizeof(sequence))));
|
||||||
|
uint64_t arrivedAt = usecTimestampNow();
|
||||||
|
uint64_t transitTime = arrivedAt - sentAt;
|
||||||
|
if (wantShowAnimationDebug() || wantsDebugVoxelReceiving()) {
|
||||||
|
printf("RECEIVE THREAD: got %s - command from client receivedBytes=%d sequence=%d transitTime=%llu usecs\n",
|
||||||
|
messageName,
|
||||||
|
dataByteArray.size(), sequence, transitTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_voxelServerPacketProcessor->queueReceivedPacket(senderSockAddr,
|
||||||
|
(unsigned char*) dataByteArray.data(), dataByteArray.size());
|
||||||
|
} else {
|
||||||
|
// let processNodeData handle it.
|
||||||
|
NodeList::getInstance()->processNodeData(senderSockAddr,
|
||||||
|
(unsigned char*) dataByteArray.data(),
|
||||||
|
dataByteArray.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//int main(int argc, const char * argv[]) {
|
//int main(int argc, const char * argv[]) {
|
||||||
void VoxelServer::run() {
|
void VoxelServer::run() {
|
||||||
|
|
||||||
|
@ -623,8 +697,6 @@ void VoxelServer::run() {
|
||||||
unsigned char* packetData = new unsigned char[MAX_PACKET_SIZE];
|
unsigned char* packetData = new unsigned char[MAX_PACKET_SIZE];
|
||||||
ssize_t packetLength;
|
ssize_t packetLength;
|
||||||
|
|
||||||
timeval lastDomainServerCheckIn = {};
|
|
||||||
|
|
||||||
// set up our jurisdiction broadcaster...
|
// set up our jurisdiction broadcaster...
|
||||||
_jurisdictionSender = new JurisdictionSender(_jurisdiction);
|
_jurisdictionSender = new JurisdictionSender(_jurisdiction);
|
||||||
if (_jurisdictionSender) {
|
if (_jurisdictionSender) {
|
||||||
|
@ -650,95 +722,21 @@ void VoxelServer::run() {
|
||||||
}
|
}
|
||||||
qDebug() << "Now running... started at: " << localBuffer << utcBuffer << "\n";
|
qDebug() << "Now running... started at: " << localBuffer << utcBuffer << "\n";
|
||||||
|
|
||||||
|
QTimer* domainServerTimer = new QTimer(this);
|
||||||
|
connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
|
||||||
|
domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_USECS / 1000);
|
||||||
|
|
||||||
|
QTimer* silentNodeTimer = new QTimer(this);
|
||||||
|
connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
|
||||||
|
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
|
||||||
|
|
||||||
|
QTimer* pingNodesTimer = new QTimer(this);
|
||||||
|
connect(pingNodesTimer, SIGNAL(timeout()), nodeList, SLOT(pingInactiveNodes()));
|
||||||
|
pingNodesTimer->start(PING_INACTIVE_NODE_INTERVAL_USECS / 1000);
|
||||||
|
|
||||||
// loop to send to nodes requesting data
|
// loop to send to nodes requesting data
|
||||||
while (true) {
|
while (!_isFinished) {
|
||||||
// check for >= in case one gets past the goalie
|
QCoreApplication::processEvents();
|
||||||
if (NodeList::getInstance()->getNumNoReplyDomainCheckIns() >= MAX_SILENT_DOMAIN_SERVER_CHECK_INS) {
|
|
||||||
qDebug() << "Exit loop... getInstance()->getNumNoReplyDomainCheckIns() >= MAX_SILENT_DOMAIN_SERVER_CHECK_INS\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// send a check in packet to the domain server if DOMAIN_SERVER_CHECK_IN_USECS has elapsed
|
|
||||||
if (usecTimestampNow() - usecTimestamp(&lastDomainServerCheckIn) >= DOMAIN_SERVER_CHECK_IN_USECS) {
|
|
||||||
gettimeofday(&lastDomainServerCheckIn, NULL);
|
|
||||||
NodeList::getInstance()->sendDomainServerCheckIn();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ping our inactive nodes to punch holes with them
|
|
||||||
nodeList->pingInactiveNodes();
|
|
||||||
|
|
||||||
if (nodeList->getNodeSocket().hasPendingDatagrams()
|
|
||||||
&& (packetLength = nodeList->getNodeSocket().readDatagram((char*) packetData, MAX_PACKET_SIZE,
|
|
||||||
senderSockAddr.getAddressPointer(),
|
|
||||||
senderSockAddr.getPortPointer()))
|
|
||||||
&& packetVersionMatch(packetData)) {
|
|
||||||
|
|
||||||
int numBytesPacketHeader = numBytesForPacketHeader(packetData);
|
|
||||||
|
|
||||||
if (packetData[0] == PACKET_TYPE_VOXEL_QUERY) {
|
|
||||||
// If we got a PACKET_TYPE_VOXEL_QUERY, then we're talking to an NODE_TYPE_AVATAR, and we
|
|
||||||
// need to make sure we have it in our nodeList.
|
|
||||||
QUuid nodeUUID = QUuid::fromRfc4122(QByteArray((char*)packetData + numBytesPacketHeader,
|
|
||||||
NUM_BYTES_RFC4122_UUID));
|
|
||||||
|
|
||||||
Node* node = nodeList->nodeWithUUID(nodeUUID);
|
|
||||||
|
|
||||||
if (node) {
|
|
||||||
nodeList->updateNodeWithData(node, senderSockAddr, packetData, packetLength);
|
|
||||||
if (!node->getActiveSocket()) {
|
|
||||||
// we don't have an active socket for this node, but they're talking to us
|
|
||||||
// this means they've heard from us and can reply, let's assume public is active
|
|
||||||
node->activatePublicSocket();
|
|
||||||
}
|
|
||||||
VoxelNodeData* nodeData = (VoxelNodeData*) node->getLinkedData();
|
|
||||||
if (nodeData && !nodeData->isVoxelSendThreadInitalized()) {
|
|
||||||
nodeData->initializeVoxelSendThread(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (packetData[0] == PACKET_TYPE_VOXEL_JURISDICTION_REQUEST) {
|
|
||||||
if (_jurisdictionSender) {
|
|
||||||
_jurisdictionSender->queueReceivedPacket(senderSockAddr, packetData, packetLength);
|
|
||||||
}
|
|
||||||
} else if (_voxelServerPacketProcessor &&
|
|
||||||
(packetData[0] == PACKET_TYPE_SET_VOXEL
|
|
||||||
|| packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE
|
|
||||||
|| packetData[0] == PACKET_TYPE_ERASE_VOXEL
|
|
||||||
|| packetData[0] == PACKET_TYPE_Z_COMMAND)) {
|
|
||||||
|
|
||||||
|
|
||||||
const char* messageName;
|
|
||||||
switch (packetData[0]) {
|
|
||||||
case PACKET_TYPE_SET_VOXEL:
|
|
||||||
messageName = "PACKET_TYPE_SET_VOXEL";
|
|
||||||
break;
|
|
||||||
case PACKET_TYPE_SET_VOXEL_DESTRUCTIVE:
|
|
||||||
messageName = "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE";
|
|
||||||
break;
|
|
||||||
case PACKET_TYPE_ERASE_VOXEL:
|
|
||||||
messageName = "PACKET_TYPE_ERASE_VOXEL";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int numBytesPacketHeader = numBytesForPacketHeader(packetData);
|
|
||||||
|
|
||||||
if (packetData[0] != PACKET_TYPE_Z_COMMAND) {
|
|
||||||
unsigned short int sequence = (*((unsigned short int*)(packetData + numBytesPacketHeader)));
|
|
||||||
uint64_t sentAt = (*((uint64_t*)(packetData + numBytesPacketHeader + sizeof(sequence))));
|
|
||||||
uint64_t arrivedAt = usecTimestampNow();
|
|
||||||
uint64_t transitTime = arrivedAt - sentAt;
|
|
||||||
if (wantShowAnimationDebug() || wantsDebugVoxelReceiving()) {
|
|
||||||
printf("RECEIVE THREAD: got %s - command from client receivedBytes=%ld sequence=%d transitTime=%llu usecs\n",
|
|
||||||
messageName,
|
|
||||||
packetLength, sequence, transitTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_voxelServerPacketProcessor->queueReceivedPacket(senderSockAddr, packetData, packetLength);
|
|
||||||
} else {
|
|
||||||
// let processNodeData handle it.
|
|
||||||
NodeList::getInstance()->processNodeData(senderSockAddr, packetData, packetLength);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call NodeList::clear() so that all of our node specific objects, including our sending threads, are
|
// call NodeList::clear() so that all of our node specific objects, including our sending threads, are
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
#include <Assignment.h>
|
#include <ThreadedAssignment.h>
|
||||||
#include <EnvironmentData.h>
|
#include <EnvironmentData.h>
|
||||||
|
|
||||||
#include "civetweb.h"
|
#include "civetweb.h"
|
||||||
|
@ -26,14 +26,13 @@
|
||||||
#include "VoxelServerPacketProcessor.h"
|
#include "VoxelServerPacketProcessor.h"
|
||||||
|
|
||||||
/// Handles assignments of type VoxelServer - sending voxels to various clients.
|
/// Handles assignments of type VoxelServer - sending voxels to various clients.
|
||||||
class VoxelServer : public Assignment {
|
class VoxelServer : public ThreadedAssignment {
|
||||||
public:
|
public:
|
||||||
VoxelServer(const unsigned char* dataBuffer, int numBytes);
|
VoxelServer(const unsigned char* dataBuffer, int numBytes);
|
||||||
|
|
||||||
~VoxelServer();
|
~VoxelServer();
|
||||||
|
|
||||||
/// runs the voxel server assignment
|
|
||||||
void run();
|
|
||||||
|
|
||||||
/// allows setting of run arguments
|
/// allows setting of run arguments
|
||||||
void setArguments(int argc, char** argv);
|
void setArguments(int argc, char** argv);
|
||||||
|
@ -59,7 +58,11 @@ public:
|
||||||
bool isInitialLoadComplete() const { return (_voxelPersistThread) ? _voxelPersistThread->isInitialLoadComplete() : true; }
|
bool isInitialLoadComplete() const { return (_voxelPersistThread) ? _voxelPersistThread->isInitialLoadComplete() : true; }
|
||||||
time_t* getLoadCompleted() { return (_voxelPersistThread) ? _voxelPersistThread->getLoadCompleted() : NULL; }
|
time_t* getLoadCompleted() { return (_voxelPersistThread) ? _voxelPersistThread->getLoadCompleted() : NULL; }
|
||||||
uint64_t getLoadElapsedTime() const { return (_voxelPersistThread) ? _voxelPersistThread->getLoadElapsedTime() : 0; }
|
uint64_t getLoadElapsedTime() const { return (_voxelPersistThread) ? _voxelPersistThread->getLoadElapsedTime() : 0; }
|
||||||
|
public slots:
|
||||||
|
/// runs the voxel server assignment
|
||||||
|
void run();
|
||||||
|
|
||||||
|
void processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr);
|
||||||
private:
|
private:
|
||||||
int _argc;
|
int _argc;
|
||||||
const char** _argv;
|
const char** _argv;
|
||||||
|
|
Loading…
Reference in a new issue