mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +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 ASSIGNMENT_SERVER_LISTEN_PORT = 7007;
|
||||||
const int MAX_PACKET_SIZE_BYTES = 1400;
|
const int MAX_PACKET_SIZE_BYTES = 1400;
|
||||||
|
|
||||||
struct Assignment {
|
struct Assignment {};
|
||||||
char birdIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
|
@ -38,26 +36,19 @@ 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)) {
|
||||||
|
|
||||||
int numHeaderBytes = numBytesForPacketHeader(senderData);
|
// int numHeaderBytes = numBytesForPacketHeader(senderData);
|
||||||
|
|
||||||
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
||||||
// grab the FI assignment in the queue, if it exists
|
// grab the FI 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();
|
||||||
|
|
||||||
printf("Pulled an assignment with index %d\n", firstAssignment.birdIndex);
|
|
||||||
|
|
||||||
assignmentPacket[numHeaderBytes] = firstAssignment.birdIndex;
|
|
||||||
|
|
||||||
// send the assignment
|
// send the assignment
|
||||||
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, sizeof(assignmentPacket));
|
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, sizeof(assignmentPacket));
|
||||||
}
|
}
|
||||||
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT) {
|
} else if (senderData[0] == PACKET_TYPE_SEND_ASSIGNMENT) {
|
||||||
Assignment newAssignment;
|
Assignment newAssignment;
|
||||||
newAssignment.birdIndex = *(senderData + numHeaderBytes);
|
|
||||||
|
|
||||||
printf("Created an assignment in the queue with %d\n", newAssignment.birdIndex);
|
|
||||||
|
|
||||||
// add this assignment to the queue
|
// add this assignment to the queue
|
||||||
assignmentQueue.push(newAssignment);
|
assignmentQueue.push(newAssignment);
|
||||||
|
|
Loading…
Reference in a new issue