I'm making code that sends and receives data from a c++ program.
Every time I receive data with setBinary(true) and restart the server, before I spawn I get a runtime error, I have no clue why this might be?
My code is as below so far, what it will do is build terrain generated in the c++ application.
package buildTerrain {
function buildTerrain(%pos1, %pos2)
{
%tcp = new TCPObject(TerrainTCPObject);
%tcp.connect("127.0.0.1:4878");
%tcp.send(%pos1 SPC %pos2);
%tcp.setBinary(true);
}
function TerrainTCPObject::downloadComplete(%this)
{
%this.saveBufferToFile("base/server/temp/terrainData");
%this.setBinary(false);
%this.disconnect();
%this.delete();
%file = new FileObject();
%file.openForRead("base/server/temp/terrainData");
%coords = %file.readLine();
%xx1 = getWord(%coords,0);
%yy1 = getWord(%coords,1);
%zz1 = getWord(%coords,2);
%xx2 = getWord(%coords,3);
%yy2 = getWord(%coords,4);
%zz2 = getWord(%coords,5);
%pos = 0;
for(%i=%xx1; %i<%xx2; %i++)
for(%j=%yy1; %j<%yy2; %j++)
for(%k=%zz1; %k<%zz2; %k++)
{
%type = %file.readLine();
}
%file.close();
%file.delete();
fileDelete("base/server/temp/terrainData");
}
function TerrainTCPObject::onBinChunk(%this,%chunk)
{
if(!%this.lengthRecieved)
{
%this.saveBufferToFile("base/server/temp/terrainData");
%file = new FileObject();
%file.openForRead("base/server/temp/terrainData");
%this.contentLength = %file.readLine();
%file.close();
%file.delete();
fileDelete("base/server/temp/terrainData");
%this.lengthRecieved = 1;
%this.setBinary(false);
%this.setBinary(true);
%this.send(NULL);
}
else
if(%chunk == %this.contentLength)
%this.downloadComplete();
}
};
deactivatePackage("buildTerrain");
activatePackage("buildTerrain");