cleanup assignment server to prepare for stub pull

This commit is contained in:
Stephen Birarda 2013-08-05 10:00:00 -07:00
parent a4ea0f035a
commit 72f76ee0b8

View file

@ -17,9 +17,7 @@
const int ASSIGNMENT_SERVER_LISTEN_PORT = 7007;
const int MAX_PACKET_SIZE_BYTES = 1400;
struct Assignment {
char birdIndex;
};
struct Assignment {};
int main(int argc, const char* argv[]) {
@ -38,26 +36,19 @@ int main(int argc, const char* argv[]) {
while (true) {
if (serverSocket.receive((sockaddr*) &senderSocket, &senderData, &receivedBytes)) {
int numHeaderBytes = numBytesForPacketHeader(senderData);
// int numHeaderBytes = numBytesForPacketHeader(senderData);
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
// grab the FI assignment in the queue, if it exists
if (assignmentQueue.size() > 0) {
Assignment firstAssignment = assignmentQueue.front();
// Assignment firstAssignment = assignmentQueue.front();
assignmentQueue.pop();
printf("Pulled an assignment with index %d\n", firstAssignment.birdIndex);
assignmentPacket[numHeaderBytes] = firstAssignment.birdIndex;
// send the assignment
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, sizeof(assignmentPacket));
}
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT) {
Assignment newAssignment;
newAssignment.birdIndex = *(senderData + numHeaderBytes);
printf("Created an assignment in the queue with %d\n", newAssignment.birdIndex);
// add this assignment to the queue
assignmentQueue.push(newAssignment);