FileDownloader.downloadFile("image.blockland.us", "/detail.php?q=74.52.20.186:28100", "base/client/ui/loadingBG.png"); is giving an empty file still, instead of badspot's pirate DM image
package ServerPreview
{
function ConnectToServer(%a, %b, %c, %d)
{
echo("triggered");
%value = parent::ConnectToServer(%a, %b, %c, %d);
%ip = getSubStr(%a,0,strPos(%a,":"));
%port = getSubStr(%a,strPos(%a,":")+1,strLen(%a));
%address = strreplace(%ip,".","-") @ "_" @ %port;
new tcpObject(FileDownloader);
FileDownloader.downloadFile("image.blockland.us", "/detail.php?q=" @ %address, "base/client/ui/loadingBG.png");
echo("ended");
return %value;
}
};
activatePackage(ServerPreview);
function FileDownloader::DownloadFile(%this, %addr, %file, %saveto)
{
%this.addr = %addr;
%this.file = %file;
%this.saveTo = %saveto;
%this.connect(%addr @ ":80");
}
function FileDownloader::onConnected(%this)
{
%this.send("GET " @ %this.file @ " HTTP/1.0\r\nHost: "@ %this.addr @"\r\n\r\n");
}
function FileDownloader::onLine(%this, %line)
{
if(%line $= "" && %this.binSize)
%this.setBinarySize(%this.binSize);
if(getWord(%line,0) $= "Content-Length:")
%this.binSize = getWord(%line,1);
}
function FileDownloader::onBinChunk(%this)
{
cancel(%this.saveSched);
%this.saveSched = %this.schedule(1000, onSaveFinal, %this.saveto);
}
function FileDownloader::onSaveFinal(%this, %saveto)
{
%this.saveBufferToFile(%saveto);
echo("done loading");
schedule(500, 0, resetLoading);
}
function resetLoading()
{
canvas.popDialog(LoadingGui);
canvas.pushDialog(LoadingGui);
}
i feel like i must've forgotten to change something in here, and done loading never echos
happens with both the if(%line $= "" && %this.binSize) %this.setBinarySize(%this.binSize); and the other one