MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / startSendingFile

Method startSendingFile

Engine/source/sim/netDownload.cpp:181–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181bool NetConnection::startSendingFile(const char *fileName)
182{
183 if(!fileName || Con::getBoolVariable("$NetConnection::neverUploadFiles"))
184 {
185 sendConnectionMessage(SendNextDownloadRequest);
186 return false;
187 }
188
189 mCurrentDownloadingFile = FileStream::createAndOpen( fileName, Torque::FS::File::Read );
190 if(!mCurrentDownloadingFile)
191 {
192 // the server didn't have the file, so send a 0 byte chunk:
193 Con::printf("No such file '%s'.", fileName);
194 postNetEvent(new FileChunkEvent(NULL, 0));
195 return false;
196 }
197
198 Con::printf("Sending file '%s'.", fileName);
199 mCurrentFileBufferSize = mCurrentDownloadingFile->getStreamSize();
200 mCurrentFileBufferOffset = 0;
201
202 // always have 32 file chunks (64 bytes each) in transit
203 sendConnectionMessage(FileDownloadSizeMessage, mCurrentFileBufferSize);
204 for(U32 i = 0; i < 32; i++)
205 sendFileChunk();
206 return true;
207}
208
209void NetConnection::sendNextFileDownloadRequest()
210{

Callers 1

processMethod · 0.80

Calls 3

getBoolVariableFunction · 0.85
printfFunction · 0.85
getStreamSizeMethod · 0.45

Tested by

no test coverage detected