mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 20:13:35 +02:00
send assignment from domain server for audio mixer if it isn't present
This commit is contained in:
parent
f3e4196a81
commit
f52c1c909b
8 changed files with 42 additions and 13 deletions
|
@ -45,8 +45,10 @@ int main(int argc, const char* argv[]) {
|
|||
// send the assignment
|
||||
}
|
||||
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT && packetVersionMatch(senderData)) {
|
||||
Assignment newAssignment(*(senderData + numBytesForPacketHeader(senderData));
|
||||
|
||||
Assignment newAssignment((Assignment::Type) *(senderData + numBytesForPacketHeader(senderData)));
|
||||
|
||||
qDebug() << "Received assignment of type " << newAssignment.getType() << "\n";
|
||||
|
||||
// add this assignment to the queue
|
||||
assignmentQueue.push(newAssignment);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Assignment.h"
|
||||
#include "NodeList.h"
|
||||
#include "NodeTypes.h"
|
||||
#include "Logstash.h"
|
||||
|
@ -85,6 +86,15 @@ int main(int argc, const char * argv[])
|
|||
timeval lastStatSendTime = {};
|
||||
|
||||
while (true) {
|
||||
|
||||
if (!nodeList->soloNodeOfType(NODE_TYPE_AUDIO_MIXER)) {
|
||||
// we don't have an audio mixer, and we know we need one
|
||||
// so tell that to the assignment server
|
||||
Assignment mixerAssignment(Assignment::AudioMixer);
|
||||
nodeList->sendAssignment(mixerAssignment);
|
||||
}
|
||||
|
||||
|
||||
if (nodeList->getNodeSocket()->receive((sockaddr *)&nodePublicAddress, packetData, &receivedBytes) &&
|
||||
(packetData[0] == PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY || packetData[0] == PACKET_TYPE_DOMAIN_LIST_REQUEST) &&
|
||||
packetVersionMatch(packetData)) {
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
};
|
||||
|
||||
Assignment(Assignment::Type type);
|
||||
|
||||
Assignment::Type getType() const { return _type; }
|
||||
private:
|
||||
Assignment::Type _type;
|
||||
};
|
||||
|
|
|
@ -366,15 +366,23 @@ int NodeList::processDomainServerList(unsigned char* packetData, size_t dataByte
|
|||
return readNodes;
|
||||
}
|
||||
|
||||
void NodeList::sendAssignmentRequest() {
|
||||
const char ASSIGNMENT_SERVER_HOSTNAME[] = "assignment.highfidelity.io";
|
||||
|
||||
static sockaddr_in assignmentServerSocket = socketForHostname(ASSIGNMENT_SERVER_HOSTNAME);
|
||||
assignmentServerSocket.sin_port = htons(ASSIGNMENT_SERVER_PORT);
|
||||
|
||||
const char ASSIGNMENT_SERVER_HOSTNAME[] = "localhost";
|
||||
const sockaddr_in assignmentServerSocket = socketForHostnameAndHostOrderPort(ASSIGNMENT_SERVER_HOSTNAME,
|
||||
ASSIGNMENT_SERVER_PORT);
|
||||
|
||||
void NodeList::requestAssignment() {
|
||||
_nodeSocket.send((sockaddr*) &assignmentServerSocket, &PACKET_TYPE_REQUEST_ASSIGNMENT, 1);
|
||||
}
|
||||
|
||||
void NodeList::sendAssignment(Assignment& assignment) {
|
||||
unsigned char assignmentPacket[MAX_PACKET_SIZE];
|
||||
int numHeaderBytes = populateTypeAndVersion(assignmentPacket, PACKET_TYPE_SEND_ASSIGNMENT);
|
||||
|
||||
qDebug() << "The socket IP is " << inet_ntoa(assignmentServerSocket.sin_addr);
|
||||
|
||||
_nodeSocket.send((sockaddr*) &assignmentServerSocket, assignmentPacket, numHeaderBytes);
|
||||
}
|
||||
|
||||
Node* NodeList::addOrUpdateNode(sockaddr* publicSocket, sockaddr* localSocket, char nodeType, uint16_t nodeId) {
|
||||
NodeList::iterator node = end();
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ extern const int DEFAULT_DOMAINSERVER_PORT;
|
|||
|
||||
const int UNKNOWN_NODE_ID = 0;
|
||||
|
||||
class Assignment;
|
||||
class NodeListIterator;
|
||||
|
||||
// Callers who want to hook add/kill callbacks should implement this class
|
||||
|
@ -95,7 +96,8 @@ public:
|
|||
void sendDomainServerCheckIn();
|
||||
int processDomainServerList(unsigned char *packetData, size_t dataBytes);
|
||||
|
||||
void sendAssignmentRequest();
|
||||
void requestAssignment();
|
||||
void sendAssignment(Assignment& assignment);
|
||||
|
||||
Node* nodeWithAddress(sockaddr *senderAddress);
|
||||
Node* nodeWithID(uint16_t nodeID);
|
||||
|
|
|
@ -57,6 +57,6 @@ const int MAX_PACKET_HEADER_BYTES = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION)
|
|||
#define ADD_SCENE_COMMAND "add scene"
|
||||
#define TEST_COMMAND "a message"
|
||||
|
||||
const int ASSIGNMENT_SERVER_PORT = 7007;
|
||||
const unsigned short ASSIGNMENT_SERVER_PORT = 7007;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <cstdio>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -118,14 +119,18 @@ unsigned short loadBufferWithSocketInfo(char* addressBuffer, sockaddr* socket) {
|
|||
}
|
||||
}
|
||||
|
||||
sockaddr_in socketForHostname(const char* hostname) {
|
||||
sockaddr_in socketForHostnameAndHostOrderPort(const char* hostname, unsigned short port) {
|
||||
struct hostent* pHostInfo;
|
||||
sockaddr_in newSocket;
|
||||
sockaddr_in newSocket = {};
|
||||
|
||||
if ((pHostInfo = gethostbyname(hostname))) {
|
||||
memcpy(&newSocket.sin_addr, pHostInfo->h_addr_list[0], pHostInfo->h_length);
|
||||
}
|
||||
|
||||
if (port != 0) {
|
||||
newSocket.sin_port = htons(port);
|
||||
}
|
||||
|
||||
return newSocket;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,6 @@ int packSocket(unsigned char* packStore, sockaddr* socketToPack);
|
|||
int unpackSocket(unsigned char* packedData, sockaddr* unpackDestSocket);
|
||||
int getLocalAddress();
|
||||
unsigned short loadBufferWithSocketInfo(char* addressBuffer, sockaddr* socket);
|
||||
sockaddr_in socketForHostname(const char* hostname);
|
||||
sockaddr_in socketForHostnameAndHostOrderPort(const char* hostname, unsigned short port = 0);
|
||||
|
||||
#endif /* defined(__interface__UDPSocket__) */
|
||||
|
|
Loading…
Reference in a new issue