mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 00:10:52 +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) {
|
if (voxelServerConfig) {
|
||||||
qDebug("Reading Voxel Server Configuration.\n");
|
qDebug("Reading Voxel Server Configuration.\n");
|
||||||
qDebug() << " config: " << voxelServerConfig << "\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
|
// 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) {
|
if (numBytes > numBytesRead) {
|
||||||
_numPayloadBytes = numBytes - numBytesRead;
|
_numPayloadBytes = numBytes - numBytesRead;
|
||||||
memcpy(_payload, dataBuffer + numBytesRead, numBytes - numBytesRead);
|
_payload = new uchar[_numPayloadBytes];
|
||||||
|
memcpy(_payload, dataBuffer + numBytesRead, _numPayloadBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assignment::~Assignment() {
|
Assignment::~Assignment() {
|
||||||
delete _attachedPublicSocket;
|
delete _attachedPublicSocket;
|
||||||
delete _attachedLocalSocket;
|
delete _attachedLocalSocket;
|
||||||
delete _payload;
|
delete[] _payload;
|
||||||
_numPayloadBytes = 0;
|
_numPayloadBytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int MAX_PAYLOAD_BYTES = 1024;
|
const int MAX_PAYLOAD_BYTES = 1024;
|
||||||
|
|
||||||
void Assignment::setPayload(uchar* payload, int numBytes) {
|
void Assignment::copyPayload(uchar* payload, int numBytes) {
|
||||||
_payload = payload;
|
|
||||||
|
|
||||||
if (numBytes > MAX_PAYLOAD_BYTES) {
|
if (numBytes > MAX_PAYLOAD_BYTES) {
|
||||||
qDebug("Set payload called with number of bytes greater than maximum (%d). Will only transfer %d bytes.\n",
|
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;
|
_numPayloadBytes = numBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] _payload;
|
||||||
|
_payload = new uchar[_numPayloadBytes];
|
||||||
|
memcpy(_payload, payload, _numPayloadBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Assignment::getUUIDStringWithoutCurlyBraces() const {
|
QString Assignment::getUUIDStringWithoutCurlyBraces() const {
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
uchar* getPayload() { return _payload; }
|
uchar* getPayload() { return _payload; }
|
||||||
int getNumPayloadBytes() const { return _numPayloadBytes; }
|
int getNumPayloadBytes() const { return _numPayloadBytes; }
|
||||||
void setPayload(uchar *payload, int numBytes);
|
void copyPayload(uchar *payload, int numBytes);
|
||||||
|
|
||||||
int getNumberOfInstances() const { return _numberOfInstances; }
|
int getNumberOfInstances() const { return _numberOfInstances; }
|
||||||
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
|
void setNumberOfInstances(int numberOfInstances) { _numberOfInstances = numberOfInstances; }
|
||||||
|
|
Loading…
Reference in a new issue