mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Send an explicit kill request to the avatar mixer (which will pass it along to
the other clients) when we exit.
This commit is contained in:
parent
184c0a67d1
commit
092515e199
5 changed files with 47 additions and 1 deletions
|
@ -146,6 +146,7 @@ void AvatarMixer::run() {
|
|||
case PACKET_TYPE_INJECT_AUDIO:
|
||||
broadcastAvatarData(nodeList, nodeUUID, &nodeAddress);
|
||||
break;
|
||||
case PACKET_TYPE_KILL_NODE:
|
||||
case PACKET_TYPE_AVATAR_URLS:
|
||||
case PACKET_TYPE_AVATAR_FACE_VIDEO:
|
||||
nodeUUID = QUuid::fromRfc4122(QByteArray((char*) packetData + numBytesForPacketHeader(packetData),
|
||||
|
@ -156,7 +157,8 @@ void AvatarMixer::run() {
|
|||
nodeList->getNodeSocket()->send(node->getActiveSocket(), packetData, receivedBytes);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// let node kills fall through to default behavior
|
||||
|
||||
default:
|
||||
// hand this off to the NodeList
|
||||
nodeList->processNodeData(&nodeAddress, packetData, receivedBytes);
|
||||
|
|
|
@ -1394,6 +1394,9 @@ void Application::terminate() {
|
|||
_rearMirrorTools->saveSettings(_settings);
|
||||
_settings->sync();
|
||||
|
||||
// let the avatar mixer know we're out
|
||||
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
||||
|
||||
if (_enableNetworkThread) {
|
||||
_stopNetworkReceiveThread = true;
|
||||
pthread_join(_networkReceiveThread, NULL);
|
||||
|
|
|
@ -162,6 +162,10 @@ void NodeList::processNodeData(sockaddr* senderAddress, unsigned char* packetDat
|
|||
processSTUNResponse(packetData, dataBytes);
|
||||
break;
|
||||
}
|
||||
case PACKET_TYPE_KILL_NODE: {
|
||||
processKillNode(packetData, dataBytes);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,6 +453,38 @@ void NodeList::processSTUNResponse(unsigned char* packetData, size_t dataBytes)
|
|||
}
|
||||
}
|
||||
|
||||
void NodeList::sendKillNode(const char* nodeTypes, int numNodeTypes) {
|
||||
unsigned char packet[MAX_PACKET_SIZE];
|
||||
unsigned char* packetPosition = packet;
|
||||
|
||||
packetPosition += populateTypeAndVersion(packetPosition, PACKET_TYPE_KILL_NODE);
|
||||
|
||||
QByteArray rfcUUID = _ownerUUID.toRfc4122();
|
||||
memcpy(packetPosition, rfcUUID.constData(), rfcUUID.size());
|
||||
packetPosition += rfcUUID.size();
|
||||
|
||||
broadcastToNodes(packet, packetPosition - packet, nodeTypes, numNodeTypes);
|
||||
}
|
||||
|
||||
void NodeList::processKillNode(unsigned char* packetData, size_t dataBytes) {
|
||||
// skip the header
|
||||
int numBytesPacketHeader = numBytesForPacketHeader(packetData);
|
||||
packetData += numBytesPacketHeader;
|
||||
dataBytes -= numBytesPacketHeader;
|
||||
|
||||
// read the node id
|
||||
QUuid nodeUUID = QUuid::fromRfc4122(QByteArray((char*)packetData, NUM_BYTES_RFC4122_UUID));
|
||||
|
||||
packetData += NUM_BYTES_RFC4122_UUID;
|
||||
dataBytes -= NUM_BYTES_RFC4122_UUID;
|
||||
|
||||
// make sure the node exists
|
||||
Node* node = nodeWithUUID(nodeUUID);
|
||||
if (node) {
|
||||
killNode(node, true);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::sendDomainServerCheckIn() {
|
||||
static bool printedDomainServerIP = false;
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ public:
|
|||
|
||||
void pingPublicAndLocalSocketsForInactiveNode(Node* node) const;
|
||||
|
||||
void sendKillNode(const char* nodeTypes, int numNodeTypes);
|
||||
|
||||
Node* nodeWithAddress(sockaddr *senderAddress);
|
||||
Node* nodeWithUUID(const QUuid& nodeUUID);
|
||||
|
||||
|
@ -155,6 +157,8 @@ private:
|
|||
void sendSTUNRequest();
|
||||
void processSTUNResponse(unsigned char* packetData, size_t dataBytes);
|
||||
|
||||
void processKillNode(unsigned char* packetData, size_t dataBytes);
|
||||
|
||||
QString _domainHostname;
|
||||
QHostAddress _domainIP;
|
||||
unsigned short _domainPort;
|
||||
|
|
|
@ -18,6 +18,7 @@ const PACKET_TYPE PACKET_TYPE_STUN_RESPONSE = 1;
|
|||
const PACKET_TYPE PACKET_TYPE_DOMAIN = 'D';
|
||||
const PACKET_TYPE PACKET_TYPE_PING = 'P';
|
||||
const PACKET_TYPE PACKET_TYPE_PING_REPLY = 'R';
|
||||
const PACKET_TYPE PACKET_TYPE_KILL_NODE = 'K';
|
||||
const PACKET_TYPE PACKET_TYPE_HEAD_DATA = 'H';
|
||||
const PACKET_TYPE PACKET_TYPE_Z_COMMAND = 'Z';
|
||||
const PACKET_TYPE PACKET_TYPE_INJECT_AUDIO = 'I';
|
||||
|
|
Loading…
Reference in a new issue