Merge pull request #922 from birarda/assignment

rename direction to command for assignment
This commit is contained in:
ZappoMan 2013-09-11 14:57:46 -07:00
commit 33cfd3a961
6 changed files with 19 additions and 19 deletions

View file

@ -53,7 +53,7 @@ void childClient() {
sockaddr_in senderSocket = {}; sockaddr_in senderSocket = {};
// create a request assignment, accept all assignments, pass the desired pool (if it exists) // create a request assignment, accept all assignments, pass the desired pool (if it exists)
Assignment requestAssignment(Assignment::RequestDirection, Assignment::AllTypes); Assignment requestAssignment(Assignment::RequestCommand, Assignment::AllTypes);
while (true) { while (true) {
if (usecTimestampNow() - usecTimestamp(&lastRequest) >= ASSIGNMENT_REQUEST_INTERVAL_USECS) { if (usecTimestampNow() - usecTimestamp(&lastRequest) >= ASSIGNMENT_REQUEST_INTERVAL_USECS) {

View file

@ -8,7 +8,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <fstream> #include <fstream>
#include <queue> #include <deque>
#include <QtCore/QString> #include <QtCore/QString>

View file

@ -19,7 +19,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <fcntl.h> #include <fcntl.h>
#include <queue> #include <deque>
#include <map> #include <map>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
@ -106,11 +106,11 @@ int main(int argc, const char* argv[]) {
// as a domain-server we will always want an audio mixer and avatar mixer // as a domain-server we will always want an audio mixer and avatar mixer
// setup the create assignments for those // setup the create assignments for those
Assignment audioMixerAssignment(Assignment::CreateDirection, Assignment audioMixerAssignment(Assignment::CreateCommand,
Assignment::AudioMixerType, Assignment::AudioMixerType,
Assignment::LocalLocation); Assignment::LocalLocation);
Assignment avatarMixerAssignment(Assignment::CreateDirection, Assignment avatarMixerAssignment(Assignment::CreateCommand,
Assignment::AvatarMixerType, Assignment::AvatarMixerType,
Assignment::LocalLocation); Assignment::LocalLocation);

View file

@ -13,8 +13,8 @@
const char IPv4_ADDRESS_DESIGNATOR = 4; const char IPv4_ADDRESS_DESIGNATOR = 4;
const char IPv6_ADDRESS_DESIGNATOR = 6; const char IPv6_ADDRESS_DESIGNATOR = 6;
Assignment::Assignment(Assignment::Direction direction, Assignment::Type type, Assignment::Location location) : Assignment::Assignment(Assignment::Command command, Assignment::Type type, Assignment::Location location) :
_direction(direction), _command(command),
_type(type), _type(type),
_location(location), _location(location),
_attachedPublicSocket(NULL), _attachedPublicSocket(NULL),
@ -35,11 +35,11 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
int numBytesRead = 0; int numBytesRead = 0;
if (dataBuffer[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) { if (dataBuffer[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
_direction = Assignment::RequestDirection; _command = Assignment::RequestCommand;
} else if (dataBuffer[0] == PACKET_TYPE_CREATE_ASSIGNMENT) { } else if (dataBuffer[0] == PACKET_TYPE_CREATE_ASSIGNMENT) {
_direction = Assignment::CreateDirection; _command = Assignment::CreateCommand;
} else if (dataBuffer[0] == PACKET_TYPE_DEPLOY_ASSIGNMENT) { } else if (dataBuffer[0] == PACKET_TYPE_DEPLOY_ASSIGNMENT) {
_direction = Assignment::DeployDirection; _command = Assignment::DeployCommand;
} }
numBytesRead += numBytesForPacketHeader(dataBuffer); numBytesRead += numBytesForPacketHeader(dataBuffer);
@ -60,7 +60,7 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
qDebug("Received a socket that cannot be unpacked!\n"); qDebug("Received a socket that cannot be unpacked!\n");
} }
if (_direction == Assignment::CreateDirection) { if (_command == Assignment::CreateCommand) {
delete _attachedLocalSocket; delete _attachedLocalSocket;
_attachedLocalSocket = newSocket; _attachedLocalSocket = newSocket;
} else { } else {

View file

@ -23,10 +23,10 @@ public:
AllTypes AllTypes
}; };
enum Direction { enum Command {
CreateDirection, CreateCommand,
DeployDirection, DeployCommand,
RequestDirection RequestCommand
}; };
enum Location { enum Location {
@ -34,7 +34,7 @@ public:
LocalLocation LocalLocation
}; };
Assignment(Assignment::Direction direction, Assignment(Assignment::Command command,
Assignment::Type type, Assignment::Type type,
Assignment::Location location = Assignment::GlobalLocation); Assignment::Location location = Assignment::GlobalLocation);
@ -45,7 +45,7 @@ public:
~Assignment(); ~Assignment();
Assignment::Direction getDirection() const { return _direction; } Assignment::Command getCommand() const { return _command; }
Assignment::Type getType() const { return _type; } Assignment::Type getType() const { return _type; }
Assignment::Location getLocation() const { return _location; } Assignment::Location getLocation() const { return _location; }
const timeval& getTime() const { return _time; } const timeval& getTime() const { return _time; }
@ -65,7 +65,7 @@ public:
void setCreateTimeToNow() { gettimeofday(&_time, NULL); } void setCreateTimeToNow() { gettimeofday(&_time, NULL); }
private: private:
Assignment::Direction _direction; /// the direction of the assignment (Create, Deploy, Request) Assignment::Command _command; /// the command for this assignment (Create, Deploy, Request)
Assignment::Type _type; /// the type of the assignment, defines what the assignee will do Assignment::Type _type; /// the type of the assignment, defines what the assignee will do
Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs Assignment::Location _location; /// the location of the assignment, allows a domain to preferentially use local ACs
sockaddr* _attachedPublicSocket; /// pointer to a public socket that relates to assignment, depends on direction sockaddr* _attachedPublicSocket; /// pointer to a public socket that relates to assignment, depends on direction

View file

@ -382,7 +382,7 @@ const sockaddr_in GLOBAL_ASSIGNMENT_SOCKET = socketForHostnameAndHostOrderPort(G
void NodeList::sendAssignment(Assignment& assignment) { void NodeList::sendAssignment(Assignment& assignment) {
unsigned char assignmentPacket[MAX_PACKET_SIZE]; unsigned char assignmentPacket[MAX_PACKET_SIZE];
PACKET_TYPE assignmentPacketType = assignment.getDirection() == Assignment::CreateDirection PACKET_TYPE assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
? PACKET_TYPE_CREATE_ASSIGNMENT ? PACKET_TYPE_CREATE_ASSIGNMENT
: PACKET_TYPE_REQUEST_ASSIGNMENT; : PACKET_TYPE_REQUEST_ASSIGNMENT;