mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
add an assignment class and begin to hookup AS
This commit is contained in:
parent
1591e11c77
commit
f3e4196a81
3 changed files with 46 additions and 30 deletions
|
@ -12,16 +12,13 @@
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
#include <Assignment.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <UDPSocket.h>
|
#include <UDPSocket.h>
|
||||||
|
|
||||||
const int MAX_PACKET_SIZE_BYTES = 1400;
|
const int MAX_PACKET_SIZE_BYTES = 1400;
|
||||||
|
|
||||||
struct Assignment {
|
|
||||||
QString scriptFilename;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
std::queue<Assignment> assignmentQueue;
|
std::queue<Assignment> assignmentQueue;
|
||||||
|
@ -37,41 +34,20 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (serverSocket.receive((sockaddr*) &senderSocket, &senderData, &receivedBytes)) {
|
if (serverSocket.receive((sockaddr*) &senderSocket, &senderData, &receivedBytes)) {
|
||||||
|
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
||||||
int numHeaderBytes = numBytesForPacketHeader(senderData);
|
|
||||||
|
|
||||||
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
|
||||||
qDebug() << "Assignment request received.\n";
|
qDebug() << "Assignment request received.\n";
|
||||||
// grab the FI assignment in the queue, if it exists
|
|
||||||
|
// grab the first assignment in the queue, if it exists
|
||||||
if (assignmentQueue.size() > 0) {
|
if (assignmentQueue.size() > 0) {
|
||||||
Assignment firstAssignment = assignmentQueue.front();
|
Assignment firstAssignment = assignmentQueue.front();
|
||||||
assignmentQueue.pop();
|
assignmentQueue.pop();
|
||||||
|
|
||||||
QString scriptURL = QString("http://base8-compute.s3.amazonaws.com/%1").arg(firstAssignment.scriptFilename);
|
|
||||||
|
|
||||||
qDebug() << "Sending assignment with URL" << scriptURL << "\n";
|
|
||||||
|
|
||||||
int scriptURLBytes = scriptURL.size();
|
|
||||||
memcpy(assignmentPacket + numSendHeaderBytes, scriptURL.toLocal8Bit().constData(), scriptURLBytes);
|
|
||||||
|
|
||||||
// send the assignment
|
// send the assignment
|
||||||
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, numHeaderBytes + scriptURLBytes);
|
|
||||||
}
|
}
|
||||||
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT) {
|
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT && packetVersionMatch(senderData)) {
|
||||||
Assignment newAssignment;
|
Assignment newAssignment(*(senderData + numBytesForPacketHeader(senderData));
|
||||||
|
|
||||||
senderData[receivedBytes] = '\0';
|
|
||||||
newAssignment.scriptFilename = QString((const char*)senderData + numHeaderBytes);
|
|
||||||
|
|
||||||
qDebug() << "Added an assignment with script with filename" << newAssignment.scriptFilename << "\n";
|
|
||||||
|
|
||||||
// add this assignment to the queue
|
// add this assignment to the queue
|
||||||
|
|
||||||
// we're not a queue right now, only keep one assignment
|
|
||||||
if (assignmentQueue.size() > 0) {
|
|
||||||
assignmentQueue.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
assignmentQueue.push(newAssignment);
|
assignmentQueue.push(newAssignment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
libraries/shared/src/Assignment.cpp
Normal file
13
libraries/shared/src/Assignment.cpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// Assignment.cpp
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 8/22/13.
|
||||||
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Assignment.h"
|
||||||
|
|
||||||
|
Assignment::Assignment(Assignment::Type type) : _type(type) {
|
||||||
|
|
||||||
|
}
|
27
libraries/shared/src/Assignment.h
Normal file
27
libraries/shared/src/Assignment.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
//
|
||||||
|
// Assignment.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 8/22/13.
|
||||||
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __hifi__Assignment__
|
||||||
|
#define __hifi__Assignment__
|
||||||
|
|
||||||
|
#include "NodeList.h"
|
||||||
|
|
||||||
|
class Assignment {
|
||||||
|
public:
|
||||||
|
enum Type {
|
||||||
|
AudioMixer
|
||||||
|
};
|
||||||
|
|
||||||
|
Assignment(Assignment::Type type);
|
||||||
|
private:
|
||||||
|
Assignment::Type _type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* defined(__hifi__Assignment__) */
|
Loading…
Reference in a new issue