mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 16:10:11 +02:00
apply refactoring changes to PACKET_TYPE_PING
This commit is contained in:
parent
e3d9289f1f
commit
6deaa5fd51
4 changed files with 15 additions and 10 deletions
|
@ -346,7 +346,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
// pull any new audio data from nodes off of the network stack
|
// pull any new audio data from nodes off of the network stack
|
||||||
while (nodeList->getNodeSocket()->receive(nodeAddress, packetData, &receivedBytes) &&
|
while (nodeList->getNodeSocket()->receive(nodeAddress, packetData, &receivedBytes) &&
|
||||||
versionForPacketType(packetData[0]) == packetData[1]) {
|
packetVersionMatch(packetData)) {
|
||||||
if (packetData[0] == PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO ||
|
if (packetData[0] == PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO ||
|
||||||
packetData[0] == PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO) {
|
packetData[0] == PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO) {
|
||||||
Node* avatarNode = nodeList->addOrUpdateNode(nodeAddress,
|
Node* avatarNode = nodeList->addOrUpdateNode(nodeAddress,
|
||||||
|
|
|
@ -80,7 +80,7 @@ void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) {
|
||||||
for(NodeList::iterator node = begin(); node != end(); node++) {
|
for(NodeList::iterator node = begin(); node != end(); node++) {
|
||||||
if (socketMatch(node->getPublicSocket(), nodeAddress) ||
|
if (socketMatch(node->getPublicSocket(), nodeAddress) ||
|
||||||
socketMatch(node->getLocalSocket(), nodeAddress)) {
|
socketMatch(node->getLocalSocket(), nodeAddress)) {
|
||||||
int pingTime = usecTimestampNow() - *(long long *)(packetData + sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION));
|
int pingTime = usecTimestampNow() - *(long long *)(packetData + numBytesForPacketHeader(packetData));
|
||||||
node->setPingMs(pingTime / 1000);
|
node->setPingMs(pingTime / 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,9 +533,9 @@ void VoxelTree::readCodeColorBufferToTreeRecursion(VoxelNode* node, void* extraD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelTree::processRemoveVoxelBitstream(unsigned char * bitstream, int bufferSizeBytes) {
|
void VoxelTree::processRemoveVoxelBitstream(unsigned char* bitstream, int bufferSizeBytes) {
|
||||||
//unsigned short int itemNumber = (*((unsigned short int*)&bitstream[sizeof(PACKET_HEADER)]));
|
//unsigned short int itemNumber = (*((unsigned short int*)&bitstream[sizeof(PACKET_HEADER)]));
|
||||||
int atByte = sizeof(short int) + sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION);
|
int atByte = sizeof(short int) + numBytesForPacketHeader(bitstream);
|
||||||
unsigned char* voxelCode = (unsigned char*)&bitstream[atByte];
|
unsigned char* voxelCode = (unsigned char*)&bitstream[atByte];
|
||||||
while (atByte < bufferSizeBytes) {
|
while (atByte < bufferSizeBytes) {
|
||||||
int codeLength = numberOfThreeBitSectionsInCode(voxelCode);
|
int codeLength = numberOfThreeBitSectionsInCode(voxelCode);
|
||||||
|
|
|
@ -637,19 +637,23 @@ int main(int argc, const char * argv[]) {
|
||||||
persistVoxelsWhenDirty();
|
persistVoxelsWhenDirty();
|
||||||
|
|
||||||
if (nodeList->getNodeSocket()->receive(&nodePublicAddress, packetData, &receivedBytes) &&
|
if (nodeList->getNodeSocket()->receive(&nodePublicAddress, packetData, &receivedBytes) &&
|
||||||
versionForPacketType(packetData[0]) == packetData[1]) {
|
packetVersionMatch(packetData)) {
|
||||||
|
|
||||||
|
int numBytesPacketHeader = numBytesForPacketHeader(packetData);
|
||||||
|
|
||||||
if (packetData[0] == PACKET_TYPE_SET_VOXEL || packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE) {
|
if (packetData[0] == PACKET_TYPE_SET_VOXEL || packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE) {
|
||||||
bool destructive = (packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE);
|
bool destructive = (packetData[0] == PACKET_TYPE_SET_VOXEL_DESTRUCTIVE);
|
||||||
PerformanceWarning warn(::shouldShowAnimationDebug,
|
PerformanceWarning warn(::shouldShowAnimationDebug,
|
||||||
destructive ? "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE" : "PACKET_TYPE_SET_VOXEL",
|
destructive ? "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE" : "PACKET_TYPE_SET_VOXEL",
|
||||||
::shouldShowAnimationDebug);
|
::shouldShowAnimationDebug);
|
||||||
unsigned short int itemNumber = (*((unsigned short int*)&packetData[2]));
|
|
||||||
|
unsigned short int itemNumber = (*((unsigned short int*)(packetData + numBytesPacketHeader)));
|
||||||
if (::shouldShowAnimationDebug) {
|
if (::shouldShowAnimationDebug) {
|
||||||
printf("got %s - command from client receivedBytes=%ld itemNumber=%d\n",
|
printf("got %s - command from client receivedBytes=%ld itemNumber=%d\n",
|
||||||
destructive ? "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE" : "PACKET_TYPE_SET_VOXEL",
|
destructive ? "PACKET_TYPE_SET_VOXEL_DESTRUCTIVE" : "PACKET_TYPE_SET_VOXEL",
|
||||||
receivedBytes,itemNumber);
|
receivedBytes,itemNumber);
|
||||||
}
|
}
|
||||||
int atByte = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(itemNumber);
|
int atByte = numBytesPacketHeader + sizeof(itemNumber);
|
||||||
unsigned char* voxelData = (unsigned char*)&packetData[atByte];
|
unsigned char* voxelData = (unsigned char*)&packetData[atByte];
|
||||||
while (atByte < receivedBytes) {
|
while (atByte < receivedBytes) {
|
||||||
unsigned char octets = (unsigned char)*voxelData;
|
unsigned char octets = (unsigned char)*voxelData;
|
||||||
|
@ -703,9 +707,10 @@ int main(int argc, const char * argv[]) {
|
||||||
|
|
||||||
// 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
|
||||||
char* command = (char*) &packetData[2]; // start of the command
|
|
||||||
|
char* command = (char*) &packetData[numBytesPacketHeader]; // start of the command
|
||||||
int commandLength = strlen(command); // commands are null terminated strings
|
int commandLength = strlen(command); // commands are null terminated strings
|
||||||
int totalLength = sizeof(PACKET_TYPE_Z_COMMAND) + commandLength + 1; // 1 for null termination
|
int totalLength = numBytesPacketHeader + commandLength + 1; // 1 for null termination
|
||||||
printf("got Z message len(%ld)= %s\n", receivedBytes, command);
|
printf("got Z message len(%ld)= %s\n", receivedBytes, command);
|
||||||
bool rebroadcast = true; // by default rebroadcast
|
bool rebroadcast = true; // by default rebroadcast
|
||||||
|
|
||||||
|
@ -736,7 +741,7 @@ int main(int argc, const char * argv[]) {
|
||||||
// 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) {
|
if (packetData[0] == PACKET_TYPE_HEAD_DATA) {
|
||||||
uint16_t nodeID = 0;
|
uint16_t nodeID = 0;
|
||||||
unpackNodeId(packetData + sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION), &nodeID);
|
unpackNodeId(packetData + numBytesPacketHeader, &nodeID);
|
||||||
Node* node = nodeList->addOrUpdateNode(&nodePublicAddress,
|
Node* node = nodeList->addOrUpdateNode(&nodePublicAddress,
|
||||||
&nodePublicAddress,
|
&nodePublicAddress,
|
||||||
NODE_TYPE_AGENT,
|
NODE_TYPE_AGENT,
|
||||||
|
|
Loading…
Reference in a new issue