repairs to subclasses of assignment

This commit is contained in:
Stephen Birarda 2013-09-17 15:20:34 -07:00
parent d830351ed6
commit 17a210813b
5 changed files with 16 additions and 4 deletions

View file

@ -11,22 +11,25 @@
#include "Agent.h"
#include "audio/AudioMixer.h"
#include "avatars/AvatarMixer.h"
#include <VoxelServer.h>
#include "AssignmentFactory.h"
Assignment* AssignmentFactory::unpackAssignment(const unsigned char* dataBuffer, int numBytes) {
int headerBytes = numBytesForPacketHeader(dataBuffer);
Assignment::Type type;
memcpy(&type, dataBuffer + headerBytes, sizeof(type));
Assignment::Type assignmentType = Assignment::AllTypes;
memcpy(&assignmentType, dataBuffer + headerBytes, sizeof(Assignment::Type));
switch (type) {
switch (assignmentType) {
case Assignment::AudioMixerType:
return new AudioMixer(dataBuffer, numBytes);
case Assignment::AvatarMixerType:
return new AvatarMixer(dataBuffer, numBytes);
case Assignment::AgentType:
return new Agent(dataBuffer, numBytes);
case Assignment::VoxelServerType:
return new VoxelServer(dataBuffer, numBytes);
default:
return new Assignment(dataBuffer, numBytes);
}

View file

@ -335,6 +335,9 @@ int main(int argc, const char* argv[]) {
if (requestAssignment.getType() == Assignment::AllTypes ||
(*assignment)->getType() == requestAssignment.getType()) {
// attach our local socket to the assignment
(*assignment)->setAttachedLocalSocket((sockaddr*) &localSocket);
// give this assignment out, either the type matches or the requestor said they will take any
int numHeaderBytes = populateTypeAndVersion(broadcastPacket, PACKET_TYPE_CREATE_ASSIGNMENT);
int numAssignmentBytes = (*assignment)->packToBuffer(broadcastPacket + numHeaderBytes);

View file

@ -154,7 +154,7 @@ int Assignment::packToBuffer(unsigned char* buffer) {
// pack the UUID for this assignment, if this is an assignment create or deploy
if (_command != Assignment::RequestCommand) {
memcpy(buffer, _uuid.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
memcpy(buffer + numPackedBytes, _uuid.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
numPackedBytes += NUM_BYTES_RFC4122_UUID;
}

View file

@ -73,6 +73,10 @@ void attachVoxelNodeDataToNode(Node* newNode) {
}
}
VoxelServer::VoxelServer(const unsigned char* dataBuffer, int numBytes) : Assignment(dataBuffer, numBytes) {
}
void VoxelServer::setArguments(int argc, char** argv) {
_argc = argc;
_argv = const_cast<const char**>(argv);

View file

@ -15,6 +15,8 @@
/// Handles assignments of type VoxelServer - sending voxels to various clients.
class VoxelServer : public Assignment {
public:
VoxelServer(const unsigned char* dataBuffer, int numBytes);
/// runs the voxel server assignment
void run();