mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 18:23:22 +02:00
cleanup assignment server to prepare for stub pull
This commit is contained in:
parent
a4ea0f035a
commit
72f76ee0b8
1 changed files with 4 additions and 13 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue