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

Method checkDebugRecv

Engine/source/console/telnetDebugger.cpp:319–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319void TelnetDebugger::checkDebugRecv()
320{
321 for (;;)
322 {
323 // Process all the complete commands in the buffer.
324 while ( mCurPos > 0 )
325 {
326 // Remove leading whitespace.
327 while ( mCurPos > 0 && ( mLineBuffer[0] == 0 || mLineBuffer[0] == '\r' || mLineBuffer[0] == '\n' ) )
328 {
329 mCurPos--;
330 dMemmove(mLineBuffer, mLineBuffer + 1, mCurPos);
331 }
332
333 // Look for a complete command.
334 bool gotCmd = false;
335 for(S32 i = 0; i < mCurPos; i++)
336 {
337 if( mLineBuffer[i] == 0 )
338 mLineBuffer[i] = '_';
339
340 else if ( mLineBuffer[i] == '\r' || mLineBuffer[i] == '\n' )
341 {
342 // Send this command to be processed.
343 mLineBuffer[i] = '\n';
344 processLineBuffer(i+1);
345
346 // Remove the command from the buffer.
347 mCurPos -= i + 1;
348 dMemmove(mLineBuffer, mLineBuffer + i + 1, mCurPos);
349
350 gotCmd = true;
351 break;
352 }
353 }
354
355 // If we didn't find a command in this pass
356 // then we have an incomplete buffer.
357 if ( !gotCmd )
358 break;
359 }
360
361 // found no <CR> or <LF>
362 if(mCurPos == MaxCommandSize) // this shouldn't happen
363 {
364 disconnect();
365 return;
366 }
367
368 S32 numBytes;
369 Net::Error err = Net::recv(mDebugSocket, (unsigned char*)(mLineBuffer + mCurPos), MaxCommandSize - mCurPos, &numBytes);
370
371 if((err != Net::NoError && err != Net::WouldBlock) || numBytes == 0)
372 {
373 disconnect();
374 return;
375 }
376 if(err == Net::WouldBlock)

Callers

nothing calls this directly

Calls 2

dMemmoveFunction · 0.50
disconnectFunction · 0.50

Tested by

no test coverage detected