mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:36:38 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
08d2c70db5
6 changed files with 34 additions and 34 deletions
|
@ -177,7 +177,7 @@ int main(int argc, const char * argv[])
|
||||||
// send the constructed list back to this node
|
// send the constructed list back to this node
|
||||||
nodeList->getNodeSocket()->send(destinationSocket,
|
nodeList->getNodeSocket()->send(destinationSocket,
|
||||||
broadcastPacket,
|
broadcastPacket,
|
||||||
(currentBufferPos - startPointer) + 1);
|
(currentBufferPos - startPointer) + numHeaderBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Logstash::shouldSendStats()) {
|
if (Logstash::shouldSendStats()) {
|
||||||
|
|
|
@ -904,15 +904,15 @@ void Application::wheelEvent(QWheelEvent* event) {
|
||||||
|
|
||||||
void Application::sendPingPackets() {
|
void Application::sendPingPackets() {
|
||||||
|
|
||||||
char nodeTypesOfInterest[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER};
|
const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER};
|
||||||
|
|
||||||
uint64_t currentTime = usecTimestampNow();
|
uint64_t currentTime = usecTimestampNow();
|
||||||
unsigned char pingPacket[numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_PING) + sizeof(currentTime)];
|
unsigned char pingPacket[numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_PING) + sizeof(currentTime)];
|
||||||
int numHeaderBytes = populateTypeAndVersion(pingPacket, PACKET_TYPE_PING);
|
int numHeaderBytes = populateTypeAndVersion(pingPacket, PACKET_TYPE_PING);
|
||||||
|
|
||||||
memcpy(&pingPacket[1], ¤tTime, sizeof(currentTime));
|
memcpy(pingPacket + numHeaderBytes, ¤tTime, sizeof(currentTime));
|
||||||
getInstance()->controlledBroadcastToNodes(pingPacket, numHeaderBytes + sizeof(currentTime),
|
getInstance()->controlledBroadcastToNodes(pingPacket, sizeof(pingPacket),
|
||||||
nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
nodesToPing, sizeof(nodesToPing));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
|
|
|
@ -180,7 +180,7 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||||
unsigned char* startPosition = sourceBuffer;
|
unsigned char* startPosition = sourceBuffer;
|
||||||
|
|
||||||
// push past the node ID
|
// push past the node ID
|
||||||
sourceBuffer += + sizeof(uint16_t);
|
sourceBuffer += sizeof(uint16_t);
|
||||||
|
|
||||||
// Body world position
|
// Body world position
|
||||||
memcpy(&_position, sourceBuffer, sizeof(float) * 3);
|
memcpy(&_position, sourceBuffer, sizeof(float) * 3);
|
||||||
|
|
|
@ -63,7 +63,10 @@ NodeList::NodeList(char newOwnerType, unsigned int newSocketListenPort) :
|
||||||
_ownerType(newOwnerType),
|
_ownerType(newOwnerType),
|
||||||
_nodeTypesOfInterest(NULL),
|
_nodeTypesOfInterest(NULL),
|
||||||
_ownerID(UNKNOWN_NODE_ID),
|
_ownerID(UNKNOWN_NODE_ID),
|
||||||
_lastNodeID(0) {
|
_lastNodeID(0),
|
||||||
|
_printedDomainServerIP(false),
|
||||||
|
_checkInPacket(NULL),
|
||||||
|
_checkInPacketSize(0) {
|
||||||
pthread_mutex_init(&mutex, 0);
|
pthread_mutex_init(&mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +221,6 @@ void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNo
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::sendDomainServerCheckIn() {
|
void NodeList::sendDomainServerCheckIn() {
|
||||||
static bool printedDomainServerIP = false;
|
|
||||||
// Lookup the IP address of the domain server if we need to
|
// Lookup the IP address of the domain server if we need to
|
||||||
if (atoi(DOMAIN_IP) == 0) {
|
if (atoi(DOMAIN_IP) == 0) {
|
||||||
struct hostent* pHostInfo;
|
struct hostent* pHostInfo;
|
||||||
|
@ -230,26 +232,23 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
} else {
|
} else {
|
||||||
printLog("Failed domain server lookup\n");
|
printLog("Failed domain server lookup\n");
|
||||||
}
|
}
|
||||||
} else if (!printedDomainServerIP) {
|
} else if (!_printedDomainServerIP) {
|
||||||
printLog("Domain Server IP: %s\n", DOMAIN_IP);
|
printLog("Domain Server IP: %s\n", DOMAIN_IP);
|
||||||
printedDomainServerIP = true;
|
_printedDomainServerIP = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct the DS check in packet if we need to
|
// construct the DS check in packet if we need to
|
||||||
static unsigned char* checkInPacket = NULL;
|
if (!_checkInPacket) {
|
||||||
static int checkInPacketSize;
|
|
||||||
|
|
||||||
const int IP_ADDRESS_BYTES = 4;
|
|
||||||
|
|
||||||
if (!checkInPacket) {
|
|
||||||
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
||||||
|
|
||||||
|
const int IP_ADDRESS_BYTES = 4;
|
||||||
|
|
||||||
// check in packet has header, node type, port, IP, node types of interest, null termination
|
// check in packet has header, node type, port, IP, node types of interest, null termination
|
||||||
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) + sizeof(uint16_t) +
|
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) + sizeof(uint16_t) +
|
||||||
IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
||||||
|
|
||||||
checkInPacket = new unsigned char[numPacketBytes];
|
_checkInPacket = new unsigned char[numPacketBytes];
|
||||||
unsigned char* packetPosition = checkInPacket;
|
unsigned char* packetPosition = _checkInPacket;
|
||||||
|
|
||||||
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
||||||
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
||||||
|
@ -260,7 +259,7 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
|
|
||||||
*(packetPosition++) = _ownerType;
|
*(packetPosition++) = _ownerType;
|
||||||
|
|
||||||
packetPosition += packSocket(checkInPacket + numHeaderBytes + sizeof(NODE_TYPE),
|
packetPosition += packSocket(_checkInPacket + numHeaderBytes + sizeof(NODE_TYPE),
|
||||||
getLocalAddress(),
|
getLocalAddress(),
|
||||||
htons(_nodeSocket.getListeningPort()));
|
htons(_nodeSocket.getListeningPort()));
|
||||||
|
|
||||||
|
@ -275,10 +274,10 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
packetPosition += numBytesNodesOfInterest;
|
packetPosition += numBytesNodesOfInterest;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInPacketSize = packetPosition - checkInPacket;
|
_checkInPacketSize = packetPosition - _checkInPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
_nodeSocket.send(DOMAIN_IP, DOMAINSERVER_PORT, checkInPacket, checkInPacketSize);
|
_nodeSocket.send(DOMAIN_IP, DOMAINSERVER_PORT, _checkInPacket, _checkInPacketSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NodeList::processDomainServerList(unsigned char* packetData, size_t dataBytes) {
|
int NodeList::processDomainServerList(unsigned char* packetData, size_t dataBytes) {
|
||||||
|
|
|
@ -113,6 +113,10 @@ private:
|
||||||
pthread_t checkInWithDomainServerThread;
|
pthread_t checkInWithDomainServerThread;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
|
bool _printedDomainServerIP;
|
||||||
|
unsigned char* _checkInPacket;
|
||||||
|
int _checkInPacketSize;
|
||||||
|
|
||||||
void handlePingReply(sockaddr *nodeAddress);
|
void handlePingReply(sockaddr *nodeAddress);
|
||||||
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// main.cpp
|
// main.cpp
|
||||||
// Voxel Server
|
// Voxel Server
|
||||||
//
|
//
|
||||||
// Created by Stephen Birara on 03/06/13.
|
// Created by Stephen Birarda on 03/06/13.
|
||||||
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -571,15 +571,13 @@ int main(int argc, const char * argv[]) {
|
||||||
voxelData += voxelDataSize;
|
voxelData += voxelDataSize;
|
||||||
atByte += voxelDataSize;
|
atByte += voxelDataSize;
|
||||||
}
|
}
|
||||||
}
|
} else if (packetData[0] == PACKET_TYPE_ERASE_VOXEL) {
|
||||||
if (packetData[0] == PACKET_TYPE_ERASE_VOXEL) {
|
|
||||||
|
|
||||||
// Send these bits off to the VoxelTree class to process them
|
// Send these bits off to the VoxelTree class to process them
|
||||||
pthread_mutex_lock(&::treeLock);
|
pthread_mutex_lock(&::treeLock);
|
||||||
serverTree.processRemoveVoxelBitstream((unsigned char*)packetData, receivedBytes);
|
serverTree.processRemoveVoxelBitstream((unsigned char*)packetData, receivedBytes);
|
||||||
pthread_mutex_unlock(&::treeLock);
|
pthread_mutex_unlock(&::treeLock);
|
||||||
}
|
} else if (packetData[0] == PACKET_TYPE_Z_COMMAND) {
|
||||||
if (packetData[0] == PACKET_TYPE_Z_COMMAND) {
|
|
||||||
|
|
||||||
// the Z command is a special command that allows the sender to send the voxel server high level semantic
|
// the Z command is a special command that allows the sender to send the voxel server high level semantic
|
||||||
// requests, like erase all, or add sphere scene
|
// requests, like erase all, or add sphere scene
|
||||||
|
@ -612,10 +610,10 @@ int main(int argc, const char * argv[]) {
|
||||||
printf("rebroadcasting Z message to connected nodes... nodeList.broadcastToNodes()\n");
|
printf("rebroadcasting Z message to connected nodes... nodeList.broadcastToNodes()\n");
|
||||||
nodeList->broadcastToNodes(packetData, receivedBytes, &NODE_TYPE_AGENT, 1);
|
nodeList->broadcastToNodes(packetData, receivedBytes, &NODE_TYPE_AGENT, 1);
|
||||||
}
|
}
|
||||||
}
|
} else if (packetData[0] == PACKET_TYPE_HEAD_DATA) {
|
||||||
// If we got a PACKET_TYPE_HEAD_DATA, then we're talking to an NODE_TYPE_AVATAR, and we
|
// If we got a PACKET_TYPE_HEAD_DATA, then we're talking to an NODE_TYPE_AVATAR, and we
|
||||||
// need to make sure we have it in our nodeList.
|
// need to make sure we have it in our nodeList.
|
||||||
if (packetData[0] == PACKET_TYPE_HEAD_DATA) {
|
|
||||||
uint16_t nodeID = 0;
|
uint16_t nodeID = 0;
|
||||||
unpackNodeId(packetData + numBytesPacketHeader, &nodeID);
|
unpackNodeId(packetData + numBytesPacketHeader, &nodeID);
|
||||||
Node* node = nodeList->addOrUpdateNode(&nodePublicAddress,
|
Node* node = nodeList->addOrUpdateNode(&nodePublicAddress,
|
||||||
|
@ -624,9 +622,8 @@ int main(int argc, const char * argv[]) {
|
||||||
nodeID);
|
nodeID);
|
||||||
|
|
||||||
nodeList->updateNodeWithData(node, packetData, receivedBytes);
|
nodeList->updateNodeWithData(node, packetData, receivedBytes);
|
||||||
}
|
} else if (packetData[0] == PACKET_TYPE_PING) {
|
||||||
// If the packet is a ping, let processNodeData handle it.
|
// If the packet is a ping, let processNodeData handle it.
|
||||||
if (packetData[0] == PACKET_TYPE_PING) {
|
|
||||||
nodeList->processNodeData(&nodePublicAddress, packetData, receivedBytes);
|
nodeList->processNodeData(&nodePublicAddress, packetData, receivedBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue