mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:56:25 +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
|
||||
nodeList->getNodeSocket()->send(destinationSocket,
|
||||
broadcastPacket,
|
||||
(currentBufferPos - startPointer) + 1);
|
||||
(currentBufferPos - startPointer) + numHeaderBytes);
|
||||
}
|
||||
|
||||
if (Logstash::shouldSendStats()) {
|
||||
|
|
|
@ -904,15 +904,15 @@ void Application::wheelEvent(QWheelEvent* event) {
|
|||
|
||||
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();
|
||||
unsigned char pingPacket[numBytesForPacketHeader((unsigned char*) &PACKET_TYPE_PING) + sizeof(currentTime)];
|
||||
int numHeaderBytes = populateTypeAndVersion(pingPacket, PACKET_TYPE_PING);
|
||||
|
||||
memcpy(&pingPacket[1], ¤tTime, sizeof(currentTime));
|
||||
getInstance()->controlledBroadcastToNodes(pingPacket, numHeaderBytes + sizeof(currentTime),
|
||||
nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
||||
memcpy(pingPacket + numHeaderBytes, ¤tTime, sizeof(currentTime));
|
||||
getInstance()->controlledBroadcastToNodes(pingPacket, sizeof(pingPacket),
|
||||
nodesToPing, sizeof(nodesToPing));
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
// push past the node ID
|
||||
sourceBuffer += + sizeof(uint16_t);
|
||||
sourceBuffer += sizeof(uint16_t);
|
||||
|
||||
// Body world position
|
||||
memcpy(&_position, sourceBuffer, sizeof(float) * 3);
|
||||
|
|
|
@ -63,7 +63,10 @@ NodeList::NodeList(char newOwnerType, unsigned int newSocketListenPort) :
|
|||
_ownerType(newOwnerType),
|
||||
_nodeTypesOfInterest(NULL),
|
||||
_ownerID(UNKNOWN_NODE_ID),
|
||||
_lastNodeID(0) {
|
||||
_lastNodeID(0),
|
||||
_printedDomainServerIP(false),
|
||||
_checkInPacket(NULL),
|
||||
_checkInPacketSize(0) {
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
}
|
||||
|
||||
|
@ -218,7 +221,6 @@ void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNo
|
|||
}
|
||||
|
||||
void NodeList::sendDomainServerCheckIn() {
|
||||
static bool printedDomainServerIP = false;
|
||||
// Lookup the IP address of the domain server if we need to
|
||||
if (atoi(DOMAIN_IP) == 0) {
|
||||
struct hostent* pHostInfo;
|
||||
|
@ -230,26 +232,23 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
} else {
|
||||
printLog("Failed domain server lookup\n");
|
||||
}
|
||||
} else if (!printedDomainServerIP) {
|
||||
} else if (!_printedDomainServerIP) {
|
||||
printLog("Domain Server IP: %s\n", DOMAIN_IP);
|
||||
printedDomainServerIP = true;
|
||||
_printedDomainServerIP = true;
|
||||
}
|
||||
|
||||
// construct the DS check in packet if we need to
|
||||
static unsigned char* checkInPacket = NULL;
|
||||
static int checkInPacketSize;
|
||||
|
||||
const int IP_ADDRESS_BYTES = 4;
|
||||
|
||||
if (!checkInPacket) {
|
||||
if (!_checkInPacket) {
|
||||
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
|
||||
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) + sizeof(uint16_t) +
|
||||
IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
||||
|
||||
checkInPacket = new unsigned char[numPacketBytes];
|
||||
unsigned char* packetPosition = checkInPacket;
|
||||
_checkInPacket = new unsigned char[numPacketBytes];
|
||||
unsigned char* packetPosition = _checkInPacket;
|
||||
|
||||
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
||||
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
||||
|
@ -260,7 +259,7 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
|
||||
*(packetPosition++) = _ownerType;
|
||||
|
||||
packetPosition += packSocket(checkInPacket + numHeaderBytes + sizeof(NODE_TYPE),
|
||||
packetPosition += packSocket(_checkInPacket + numHeaderBytes + sizeof(NODE_TYPE),
|
||||
getLocalAddress(),
|
||||
htons(_nodeSocket.getListeningPort()));
|
||||
|
||||
|
@ -275,10 +274,10 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
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) {
|
||||
|
|
|
@ -113,6 +113,10 @@ private:
|
|||
pthread_t checkInWithDomainServerThread;
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
bool _printedDomainServerIP;
|
||||
unsigned char* _checkInPacket;
|
||||
int _checkInPacketSize;
|
||||
|
||||
void handlePingReply(sockaddr *nodeAddress);
|
||||
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// main.cpp
|
||||
// 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.
|
||||
//
|
||||
|
||||
|
@ -571,15 +571,13 @@ int main(int argc, const char * argv[]) {
|
|||
voxelData += voxelDataSize;
|
||||
atByte += voxelDataSize;
|
||||
}
|
||||
}
|
||||
if (packetData[0] == PACKET_TYPE_ERASE_VOXEL) {
|
||||
} else if (packetData[0] == PACKET_TYPE_ERASE_VOXEL) {
|
||||
|
||||
// Send these bits off to the VoxelTree class to process them
|
||||
pthread_mutex_lock(&::treeLock);
|
||||
serverTree.processRemoveVoxelBitstream((unsigned char*)packetData, receivedBytes);
|
||||
pthread_mutex_unlock(&::treeLock);
|
||||
}
|
||||
if (packetData[0] == PACKET_TYPE_Z_COMMAND) {
|
||||
} else 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
|
||||
// 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");
|
||||
nodeList->broadcastToNodes(packetData, receivedBytes, &NODE_TYPE_AGENT, 1);
|
||||
}
|
||||
}
|
||||
// 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.
|
||||
if (packetData[0] == PACKET_TYPE_HEAD_DATA) {
|
||||
} 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
|
||||
// need to make sure we have it in our nodeList.
|
||||
|
||||
uint16_t nodeID = 0;
|
||||
unpackNodeId(packetData + numBytesPacketHeader, &nodeID);
|
||||
Node* node = nodeList->addOrUpdateNode(&nodePublicAddress,
|
||||
|
@ -624,9 +622,8 @@ int main(int argc, const char * argv[]) {
|
|||
nodeID);
|
||||
|
||||
nodeList->updateNodeWithData(node, packetData, receivedBytes);
|
||||
}
|
||||
// If the packet is a ping, let processNodeData handle it.
|
||||
if (packetData[0] == PACKET_TYPE_PING) {
|
||||
} else if (packetData[0] == PACKET_TYPE_PING) {
|
||||
// If the packet is a ping, let processNodeData handle it.
|
||||
nodeList->processNodeData(&nodePublicAddress, packetData, receivedBytes);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue