mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:37:19 +02:00
confirm assignment pool match before deploying assignment
This commit is contained in:
parent
6e736ff9ed
commit
a7f7dbcb31
1 changed files with 15 additions and 7 deletions
|
@ -35,20 +35,28 @@ 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)) {
|
||||||
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
if (senderData[0] == PACKET_TYPE_REQUEST_ASSIGNMENT) {
|
||||||
qDebug() << "Assignment request received.\n";
|
// construct the requested assignment from the packet data
|
||||||
|
int numHeaderBytes = numBytesForPacketHeader(senderData);
|
||||||
|
Assignment requestAssignment(senderData + numHeaderBytes, receivedBytes - numHeaderBytes);
|
||||||
|
|
||||||
|
|
||||||
// grab the first assignment in the queue, if it exists
|
// grab the first 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();
|
|
||||||
|
|
||||||
int numAssignmentBytes = firstAssignment.packToBuffer(assignmentPacket + numSendHeaderBytes);
|
// make sure there is a pool match for the created and requested assignment
|
||||||
|
if (firstAssignment.getPool() && requestAssignment.getPool()
|
||||||
// send the assignment
|
&& strcmp(firstAssignment.getPool(), requestAssignment.getPool())) {
|
||||||
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, numSendHeaderBytes + numAssignmentBytes);
|
assignmentQueue.pop();
|
||||||
|
|
||||||
|
int numAssignmentBytes = firstAssignment.packToBuffer(assignmentPacket + numSendHeaderBytes);
|
||||||
|
|
||||||
|
// send the assignment
|
||||||
|
serverSocket.send((sockaddr*) &senderSocket, assignmentPacket, numSendHeaderBytes + numAssignmentBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (senderData[0] == PACKET_TYPE_CREATE_ASSIGNMENT && packetVersionMatch(senderData)) {
|
} else if (senderData[0] == PACKET_TYPE_CREATE_ASSIGNMENT && packetVersionMatch(senderData)) {
|
||||||
// memcpy the sent assignment
|
// construct the create assignment from the packet data
|
||||||
int numHeaderBytes = numBytesForPacketHeader(senderData);
|
int numHeaderBytes = numBytesForPacketHeader(senderData);
|
||||||
Assignment createdAssignment(senderData + numHeaderBytes, receivedBytes - numHeaderBytes);
|
Assignment createdAssignment(senderData + numHeaderBytes, receivedBytes - numHeaderBytes);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue