MCPcopy Create free account
hub / github.com/SoarGroup/Soar / SendMessageGetResponse

Method SendMessageGetResponse

Core/ConnectionSML/src/sml_Connection.cpp:486–549  ·  view source on GitHub ↗

include include include "soar_instance.h" * @brief Send a message and get the response. * * @param pAnalysis This will be filled in with the analyzed response * @param pMsg The message to send * @returns True if got a reply and there were no errors. *************************************************************/

Source from the content-addressed store, hash-verified

484* @returns True if got a reply and there were no errors.
485*************************************************************/
486bool Connection::SendMessageGetResponse(AnalyzeXML* pAnalysis, ElementXML* pMsg)
487{
488 // If the connection is already closed, don't do anything
489 if (IsClosed())
490 {
491 return false ;
492 }
493
494 // Make sure only one thread is sending messages at a time
495 // (This allows us to run a separate thread in clients polling for events even
496 // when the client is sleeping, but we don't want them both to be sending/receiving at the same time).
497 soar_thread::Lock lock(&m_ClientMutex) ;
498
499 // Send the command over.
500 SendMsg(pMsg);
501
502 // There was an error in the send, so we're done.
503 if (HadError())
504 {
505 return false ;
506 }
507
508 // Get the response
509 ElementXML* pResponse = GetResponse(pMsg) ;
510
511 // These was an error in getting the response
512 if (HadError())
513 {
514 return false ;
515 }
516
517 if (!pResponse)
518 {
519 // We failed to get a reply when one was expected
520 SetError(Error::kFailedToGetResponse) ;
521 return false ;
522 }
523
524 // Analyze the response and return the analysis
525 pAnalysis->Analyze(pResponse) ;
526
527#ifdef _DEBUG
528 char* pMsgText = pResponse->GenerateXMLString(true) ;
529 pResponse->DeleteString(pMsgText) ;
530#endif
531
532 delete pResponse ;
533
534 // If the response is not SML, return false
535 if (!pAnalysis->IsSML())
536 {
537 SetError(Error::kResponseIsNotSML) ;
538 return false ;
539 }
540
541 // If we got an error, return false.
542 if (pAnalysis->GetErrorTag())
543 {

Callers 6

FlushOutputMethod · 0.80
HandleFilterEventMethod · 0.80
HandleEventMethod · 0.80
ExecuteRhsCommandMethod · 0.80
SendEventMethod · 0.80
CommitMethod · 0.80

Calls 7

HadErrorFunction · 0.85
SetErrorFunction · 0.85
AnalyzeMethod · 0.80
IsSMLMethod · 0.80
GetErrorTagMethod · 0.80
GenerateXMLStringMethod · 0.45
DeleteStringMethod · 0.45

Tested by

no test coverage detected