mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
fixes to payload in Assignment
This commit is contained in:
parent
b6548303d1
commit
3fde2887a3
3 changed files with 9 additions and 6 deletions
|
@ -167,7 +167,7 @@ int main(int argc, const char* argv[]) {
|
|||
if (voxelServerConfig) {
|
||||
qDebug("Reading Voxel Server Configuration.\n");
|
||||
qDebug() << " config: " << voxelServerConfig << "\n";
|
||||
voxelServerAssignment.setPayload((uchar*)voxelServerConfig, strlen(voxelServerConfig) + 1);
|
||||
voxelServerAssignment.copyPayload((uchar*)voxelServerConfig, strlen(voxelServerConfig) + 1);
|
||||
}
|
||||
|
||||
// construct a local socket to send with our created assignments to the global AS
|
||||
|
|
|
@ -88,21 +88,21 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
|
|||
|
||||
if (numBytes > numBytesRead) {
|
||||
_numPayloadBytes = numBytes - numBytesRead;
|
||||
memcpy(_payload, dataBuffer + numBytesRead, numBytes - numBytesRead);
|
||||
_payload = new uchar[_numPayloadBytes];
|
||||
memcpy(_payload, dataBuffer + numBytesRead, _numPayloadBytes);
|
||||
}
|
||||
}
|
||||
|
||||
Assignment::~Assignment() {
|
||||
delete _attachedPublicSocket;
|
||||
delete _attachedLocalSocket;
|
||||
delete _payload;
|
||||
delete[] _payload;
|
||||
_numPayloadBytes = 0;
|
||||
}
|
||||
|
||||
const int MAX_PAYLOAD_BYTES = 1024;
|
||||
|
||||
void Assignment::setPayload(uchar* payload, int numBytes) {
|
||||
_payload = payload;
|
||||
void Assignment::copyPayload(uchar* payload, int numBytes) {
|
||||
|
||||
if (numBytes > MAX_PAYLOAD_BYTES) {
|
||||
qDebug("Set payload called with number of bytes greater than maximum (%d). Will only transfer %d bytes.\n",
|
||||
|
@ -114,6 +114,9 @@ void Assignment::setPayload(uchar* payload, int numBytes) {
|
|||
_numPayloadBytes = numBytes;
|
||||
}
|
||||
|
||||
delete[] _payload;
|
||||
_payload = new uchar[_numPayloadBytes];
|
||||
memcpy(_payload, payload, _numPayloadBytes);
|
||||
}
|
||||
|
||||
QString Assignment::getUUIDStringWithoutCurlyBraces() const {
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
uchar* getPayload() { return _payload; }
|
||||
int getNumPayloadBytes() const { return _numPayloadBytes; }
|
||||
void setPayload(uchar *payload, int numBytes);
|
||||
void copyPayload(uchar *payload, int numBytes);
|
||||
|
||||
int getNumberOfInstances() const { return _numberOfInstances; }
|
||||
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
|
||||
|
|
Loading…
Reference in a new issue