send correctly sized packet for assignment

This commit is contained in:
Stephen Birarda 2013-08-22 11:52:59 -07:00
parent f52c1c909b
commit 2804d286d5
3 changed files with 9 additions and 3 deletions

View file

@ -49,6 +49,11 @@ int main(int argc, const char* argv[]) {
qDebug() << "Received assignment of type " << newAssignment.getType() << "\n";
// for the puroposes of debugging before implementing a GUID system - only keep latest
if (assignmentQueue.size() > 0) {
assignmentQueue.pop();
}
// add this assignment to the queue
assignmentQueue.push(newAssignment);
}

View file

@ -13,6 +13,7 @@
class Assignment {
public:
enum Type {
AudioMixer
};

View file

@ -13,6 +13,7 @@
#include <QtCore/QDebug>
#include "Assignment.h"
#include "NodeList.h"
#include "NodeTypes.h"
#include "PacketHeaders.h"
@ -377,10 +378,9 @@ void NodeList::requestAssignment() {
void NodeList::sendAssignment(Assignment& assignment) {
unsigned char assignmentPacket[MAX_PACKET_SIZE];
int numHeaderBytes = populateTypeAndVersion(assignmentPacket, PACKET_TYPE_SEND_ASSIGNMENT);
qDebug() << "The socket IP is " << inet_ntoa(assignmentServerSocket.sin_addr);
*(assignmentPacket + numHeaderBytes) = assignment.getType();
_nodeSocket.send((sockaddr*) &assignmentServerSocket, assignmentPacket, numHeaderBytes);
_nodeSocket.send((sockaddr*) &assignmentServerSocket, assignmentPacket, numHeaderBytes + sizeof(unsigned char));
}
Node* NodeList::addOrUpdateNode(sockaddr* publicSocket, sockaddr* localSocket, char nodeType, uint16_t nodeId) {