#include <CCommunicationHandler.h>
Public Member Functions | |
| void | setSocket (int inSocket) |
| setting the communication socket for this session | |
| string | preamble () |
| string | frame (const string &inSession, const string &inString) |
| string | toAttribute (string inName, string inString) |
| string | toAttribute (string inName, int inInt) |
| string | toAttribute (string inName, double inFloat) |
| int | sendError (const string &inSession, const string &inMessage) |
| void | openSession (const string &inUserName, const string &inSessionName) |
| void | renameSession (const string &inSessionID, const string &inNewName) |
| void | deleteSession (const string &inName) |
| void | getPropertySheet (const string &inSessionID, const string &inAlgorithmID) |
| int | sendHandshake (const string &inUser) |
| void | getSessions (const string &inUser) |
| void | getCollections () |
| void | getAlgorithms () |
| int | sendResult (const string &inSession, const CXMLElement &inRLL) |
| int | sendRandomImages (const string &inSession, const string &inAlgorithm, const string &inCollection, const string &inNumberOfImages) |
| void | setResultSize (int inResultSize) |
| void | setResultCutoff (const string &inCutoff) |
| void | setResultCutoff (double inCutoff) |
| void | setCollectionID (const string &inID) |
| void | setAlgorithmID (const string &inID) |
| void | startTreeBuilding (const char *inElementName, const char *const *const inAttributes) |
| void | addToCurrentTree (const char *inElementName, const char *const *const inAttributes) |
| void | moveUpCurrentTree () |
| bool | isBuildingTree () const |
| void | parseString (const string &inMessage) |
| void | clearAlgorithmElement () |
| void | startAlgorithmElement (const char *inName, const char *const *const inAttributes) |
| void | endAlgorithmElement () |
| void | initAlgorithmElement () |
| CAlgorithm * | readAlgorithmElement () |
| void | endConfiguration () |
| void | clearParsingFinished () |
| void | setParsingFinished () |
| bool | isParsingFinished () const |
| bool | readAndParse () |
| void | makeParser () |
| void | startMultiRequest (const string &inSessionID, const string &inLanguageCode="en") |
| void | endMultiRequest () |
| void | addToMultiResponse (CXMLElement *inElement) |
| const string | getCurrentSessionID () |
| CSessionManager & | getSessionManager () |
| void | incrementQueryAtRandomCount () |
| int | getQueryAtRandomCount () const |
| void | setPeerAddressString (string) |
| const string & | getPeerAddressString () const |
| CCommunicationHandler (CSessionManager &inSessionManager, ofstream &inLogFile) | |
| ~CCommunicationHandler () | |
Public Attributes | |
| CSelfDestroyPointer< CXMLElement > | mMultiResponse |
| CXMLElement * | gQueryImages |
| string | mSessionID |
| int | mResultSize |
| double | mCutoff |
| string | mCollection |
| string | mAlgorithm |
| bool | mParsingFinished |
Protected Attributes | |
| int | mQueryAtRandomCount |
| int | mSocket |
| ofstream & | mLog |
Private Attributes | |
| CSelfDestroyPointer< CXMLElement > | mDocumentRoot |
| XML_Parser | mParser |
| CSessionManager & | mSessionManager |
| CAlgorithm * | mAlgorithmTree |
| CSelfDestroyPointer< CXMLElement > | mCurrentTree |
| string | mPeerAddressString |
Definition at line 54 of file CCommunicationHandler.h.
| CCommunicationHandler::CCommunicationHandler | ( | CSessionManager & | inSessionManager, | |
| ofstream & | inLogFile | |||
| ) |
constructor/destructor
Constructing an expat parser
Definition at line 852 of file CCommunicationHandler.cc.
References makeParser(), mCutoff, mParser, and mResultSize.
00853 : 00854 mSessionManager(inSessionManager), 00855 mLog(inLogFile), 00856 mQueryAtRandomCount(0), 00857 mCurrentTree(0){ 00858 mResultSize=0; 00859 mCutoff=0.0; 00861 mParser=0; 00862 makeParser(); 00863 } CCommunicationHandler::~CCommunicationHandler(){
| CCommunicationHandler::~CCommunicationHandler | ( | ) |
Definition at line 864 of file CCommunicationHandler.cc.
References gMutex, CMutex::lock(), mParser, and CMutex::unlock().
00864 { 00865 //deleting the expat parser 00866 gMutex->lock(); 00867 XML_ParserFree(mParser); 00868 gMutex->unlock(); 00869 00870 }
| void CCommunicationHandler::setSocket | ( | int | inSocket | ) |
setting the communication socket for this session
communications: setting the communication socket for this session
Definition at line 355 of file CCommunicationHandler.cc.
References mSocket.
Referenced by main(), and processMessage().
00355 { 00356 mSocket=inSocket; 00357 }
| string CCommunicationHandler::preamble | ( | ) |
helpers for creating mrml messages the preamble for a session
Definition at line 362 of file CCommunicationHandler.cc.
Referenced by endMultiRequest(), and frame().
00362 { 00363 //ZORAN: I had to change this to something that is available all the time. 00364 // BTW, this also preoduced a Socket Error, namely a connection refused, 00365 // but was not linked to our problems. 00366 return string("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n " 00367 //"<!DOCTYPE mrml SYSTEM \"http://isrpc85.epfl.ch/Circus/code/mrml.dtd\">\n" 00368 //"<!DOCTYPE mrml SYSTEM \"http://isrpc85.epfl.ch/Circus/code/mrml.dtd\">\n" 00369 ); 00370 }
| string CCommunicationHandler::frame | ( | const string & | inSession, | |
| const string & | inString | |||
| ) |
Frame: this is for all messages the same
Definition at line 374 of file CCommunicationHandler.cc.
References preamble().
Referenced by sendHandshake().
00375 { 00376 return string(preamble()+"<mrml session-id=\""+inSession+"\">\n"+inString+"\n</mrml>\n"); 00377 }
| string CCommunicationHandler::toAttribute | ( | string | inName, | |
| string | inString | |||
| ) |
| string CCommunicationHandler::toAttribute | ( | string | inName, | |
| int | inInt | |||
| ) |
Definition at line 390 of file CCommunicationHandler.cc.
00391 { 00392 00393 char lBuffer[20]; 00394 sprintf(lBuffer,"%d",inInt); 00395 00396 string lString(lBuffer); 00397 return 00398 inName 00399 +string("\"") 00400 +lBuffer 00401 +string("\" "); 00402 }
| string CCommunicationHandler::toAttribute | ( | string | inName, | |
| double | inFloat | |||
| ) |
Definition at line 404 of file CCommunicationHandler.cc.
00405 { 00406 00407 char lBuffer[20]; 00408 sprintf(lBuffer,"%lf",inFloat); 00409 00410 string lString(lBuffer); 00411 return 00412 inName 00413 +string("=\"") 00414 +lBuffer 00415 +string("\""); 00416 }
| int CCommunicationHandler::sendError | ( | const string & | inSession, | |
| const string & | inMessage | |||
| ) |
turning a relevance level element into a string (obsolete) Error message
Definition at line 445 of file CCommunicationHandler.cc.
References CXMLElement::addAttribute().
00446 { 00447 00448 00449 CXMLElement* lErrorElement=new CXMLElement("error",0); 00450 00451 lErrorElement->addAttribute("message",inMessage); 00452 }
| void CCommunicationHandler::openSession | ( | const string & | inUserName, | |
| const string & | inSessionName | |||
| ) |
Opening a session
Definition at line 455 of file CCommunicationHandler.cc.
References addToMultiResponse(), mMultiResponse, mSessionManager, CSessionManager::openSession(), and mrml_const::session_id.
Referenced by CXEVCommunication::startVisit().
00456 { 00457 00458 CXMLElement* lOpenedSession(mSessionManager.openSession(inUserName, 00459 "", 00460 inSessionName)); 00461 //HACK to change the session of the multi response 00462 if(lOpenedSession){ 00463 string lNewID(lOpenedSession->stringReadAttribute(mrml_const::session_id).second); 00464 00465 cout << mMultiResponse->stringReadAttribute(mrml_const::session_id).second 00466 << "-> new Session ID: " 00467 << lNewID 00468 << endl; 00469 00470 mMultiResponse->addAttribute(string(mrml_const::session_id), 00471 lNewID); 00472 cout << "current state in multi reponse :" 00473 << mMultiResponse->stringReadAttribute(mrml_const::session_id).second 00474 << endl; 00475 } 00476 addToMultiResponse(lOpenedSession); 00477 }
| void CCommunicationHandler::renameSession | ( | const string & | inSessionID, | |
| const string & | inNewName | |||
| ) |
renaming the current session
Definition at line 479 of file CCommunicationHandler.cc.
References addToMultiResponse(), mSessionManager, and CSessionManager::renameSession().
Referenced by CXEVCommunication::startVisit().
00480 { 00481 addToMultiResponse(mSessionManager.renameSession(inSessionID, 00482 inName)); 00483 //FIXME : here we need to do SOMETHING 00484 }
| void CCommunicationHandler::deleteSession | ( | const string & | inName | ) |
renaming the current session
Definition at line 486 of file CCommunicationHandler.cc.
References addToMultiResponse(), CSessionManager::deleteSession(), and mSessionManager.
Referenced by CXEVCommunication::startVisit().
00486 { 00487 addToMultiResponse(mSessionManager.deleteSession(inSessionID)); 00488 }
| void CCommunicationHandler::getPropertySheet | ( | const string & | inSessionID, | |
| const string & | inAlgorithmID | |||
| ) |
Gets the property sheet contained in the algorithm with inAlgorithmID
Definition at line 490 of file CCommunicationHandler.cc.
References addToMultiResponse(), CSessionManager::getPropertySheet(), and mSessionManager.
Referenced by CXEVCommunication::startVisit().
00491 { 00492 CXMLElement* lPropertySheet(mSessionManager.getPropertySheet(inSessionID, 00493 inAlgorithmID)); 00494 if(lPropertySheet){ 00495 addToMultiResponse(lPropertySheet); 00496 } 00497 }
| int CCommunicationHandler::sendHandshake | ( | const string & | inUser | ) |
the handshake message (old MRML)
Definition at line 501 of file CCommunicationHandler.cc.
References frame(), gMutex, CMutex::lock(), mLog, mSessionManager, mSocket, sendMessage(), CSessionManager::toXMLHandshake(), and CMutex::unlock().
Referenced by CXEVCommunication::startVisit().
00501 { 00502 00503 //at present this is only a dummy 00504 gMutex->lock(); 00505 pair<string,string> 00506 lSessionIDHandshakePair=mSessionManager.toXMLHandshake(inUser); 00507 00508 string& lNewestSession(lSessionIDHandshakePair.first); 00509 string& lHandshake(lSessionIDHandshakePair.second); 00510 00511 int lReturnValue(sendMessage(mSocket, 00512 frame(lNewestSession, 00513 lHandshake).c_str(), 00514 mLog)); 00515 gMutex->unlock(); 00516 return lReturnValue; 00517 }
| void CCommunicationHandler::getSessions | ( | const string & | inUser | ) |
getting the sessions for one user (new MRML)
Definition at line 520 of file CCommunicationHandler.cc.
Referenced by CXEVCommunication::startVisit().
| void CCommunicationHandler::getCollections | ( | ) |
getting collections available on a system
Definition at line 525 of file CCommunicationHandler.cc.
References addToMultiResponse(), CSessionManager::getCollections(), and mSessionManager.
Referenced by CXEVCommunication::startVisit().
00525 { 00526 CXMLElement* lCollectionList(mSessionManager.getCollections()); 00527 addToMultiResponse(lCollectionList); 00528 }
| void CCommunicationHandler::getAlgorithms | ( | ) |
getting algorithms available on a system
Definition at line 530 of file CCommunicationHandler.cc.
References addToMultiResponse(), CSessionManager::getAlgorithms(), and mSessionManager.
Referenced by CXEVCommunication::startVisit().
00530 { 00531 CXMLElement* lAlgorithms(mSessionManager.getAlgorithms()); 00532 addToMultiResponse(lAlgorithms); 00533 }
| int CCommunicationHandler::sendResult | ( | const string & | inSession, | |
| const CXMLElement & | inRLL | |||
| ) |
| int CCommunicationHandler::sendRandomImages | ( | const string & | inSession, | |
| const string & | inAlgorithm, | |||
| const string & | inCollection, | |||
| const string & | inNumberOfImages | |||
| ) |
random images
Definition at line 544 of file CCommunicationHandler.cc.
References addToMultiResponse(), CSessionManager::getRandomImages(), and mSessionManager.
Referenced by CXEVCommunication::startVisit().
00547 { 00548 00549 int lNumberOfImages=atoi(inNumberOfImages.c_str()); 00550 00551 CXMLElement* 00552 lRLL=mSessionManager.getRandomImages(inSession, 00553 inAlgorithm, 00554 lNumberOfImages); 00555 00556 cout << "SENDRANDOM" 00557 << endl 00558 << flush; 00559 00560 addToMultiResponse(lRLL); 00561 return true; 00562 };
| void CCommunicationHandler::setResultSize | ( | int | inResultSize | ) |
setting properties of the query
Definition at line 567 of file CCommunicationHandler.cc.
References mResultSize.
00567 { 00568 mResultSize=inResultSize; 00569 }
| void CCommunicationHandler::setResultCutoff | ( | const string & | inCutoff | ) |
Definition at line 571 of file CCommunicationHandler.cc.
00571 { 00572 setResultCutoff(atof(inCutoff.c_str())); 00573 }
| void CCommunicationHandler::setResultCutoff | ( | double | inCutoff | ) |
Definition at line 574 of file CCommunicationHandler.cc.
References mCutoff.
00574 { 00575 mCutoff=inCutoff; 00576 }
| void CCommunicationHandler::setCollectionID | ( | const string & | inID | ) |
Definition at line 578 of file CCommunicationHandler.cc.
References mCollection.
00578 { 00579 mCollection=inID; 00580 }
| void CCommunicationHandler::setAlgorithmID | ( | const string & | inID | ) |
Definition at line 582 of file CCommunicationHandler.cc.
References mAlgorithm.
00582 { 00583 mAlgorithm=inID; 00584 }
| void CCommunicationHandler::startTreeBuilding | ( | const char * | inElementName, | |
| const char *const *const | inAttributes | |||
| ) |
Start building a tree by successive adding of XML elements
Start building a tree by successive adding of XML elements
Definition at line 825 of file CCommunicationHandler.cc.
References mCurrentTree.
00826 { 00827 mCurrentTree=new CXMLElement(inElementName, 00828 inAttributes); 00829 };
| void CCommunicationHandler::addToCurrentTree | ( | const char * | inElementName, | |
| const char *const *const | inAttributes | |||
| ) |
Start building a tree by successive adding of XML elements
Start building a tree by successive adding of XML elements
Definition at line 832 of file CCommunicationHandler.cc.
References mCurrentTree.
00833 { 00834 mCurrentTree->addChild(new CXMLElement(inElementName, 00835 inAttributes)); 00836 };
| void CCommunicationHandler::moveUpCurrentTree | ( | ) |
move up in the tree
move up in the tree
Definition at line 840 of file CCommunicationHandler.cc.
References mCurrentTree.
00840 { 00841 mCurrentTree->moveUp(); 00842 };
| bool CCommunicationHandler::isBuildingTree | ( | ) | const |
is this building a tree at present?
is this building a tree at present?
Definition at line 846 of file CCommunicationHandler.cc.
References mCurrentTree.
00846 { 00847 return (mCurrentTree && (!mCurrentTree->isSubtreeFinished())); 00848 };
| void CCommunicationHandler::parseString | ( | const string & | inMessage | ) |
parse XML using expat
Definition at line 589 of file CCommunicationHandler.cc.
References gMutex, CMutex::lock(), mDocumentRoot, mParser, and CMutex::unlock().
00589 { 00590 gMutex->lock(); 00591 bool lDone=false; 00592 do { 00593 if (!XML_Parse(mParser, 00594 inMessage.c_str(), 00595 inMessage.size(), 00596 lDone)) { 00597 cerr << "CCommunicationHandler.cc: __LINE__ XML ERROR: " 00598 << XML_ErrorString(XML_GetErrorCode(mParser)) 00599 << " at line " 00600 << XML_GetCurrentLineNumber(mParser) 00601 << endl; 00602 00603 mDocumentRoot=0; 00604 00605 return;// instead of exit 00606 } 00607 } while (!lDone); 00608 gMutex->unlock(); 00609 }
| void CCommunicationHandler::clearAlgorithmElement | ( | ) |
Clear the algorithm tree element. We do not assume destruction responsability here
This responsability is transferred to the containing session.
FIXME do something cleaner for the case of failure
Clears the algorithmTree element
Definition at line 763 of file CCommunicationHandler.cc.
References mAlgorithmTree.
00763 { 00764 00765 mAlgorithmTree=0; 00766 };
| void CCommunicationHandler::startAlgorithmElement | ( | const char * | inName, | |
| const char *const *const | inAttributes | |||
| ) |
start of an element in the tree of configured algorithms.
If mAlgorithm=0 then generate a new XML element with the content given by inName and inAttributes
| inName | The name like given by expat | |
| inAttributes | an attributes list like given by expat |
Definition at line 773 of file CCommunicationHandler.cc.
References CAlgorithm::addChild(), and mAlgorithmTree.
00774 { 00775 if(!mAlgorithmTree){ 00776 mAlgorithmTree=new CAlgorithm(inName,inAttributes); 00777 }else{ 00778 mAlgorithmTree->addChild(inName,inAttributes); 00779 } 00780 };
| void CCommunicationHandler::endAlgorithmElement | ( | ) |
end of an element in the tree of configured algorithms
end of an element in the tree of configured algorithms
Definition at line 786 of file CCommunicationHandler.cc.
References mAlgorithmTree, and CXMLElement::moveUp().
00786 { 00787 if(mAlgorithmTree){ 00788 mAlgorithmTree->moveUp(); 00789 } 00790 };
| void CCommunicationHandler::initAlgorithmElement | ( | ) |
clear the pointer to the algorithm tree
clear the pointer to the algorithm tree
Definition at line 796 of file CCommunicationHandler.cc.
References mAlgorithmTree.
00796 { 00797 mAlgorithmTree=0; 00798 };
| CAlgorithm * CCommunicationHandler::readAlgorithmElement | ( | ) |
read the pointer to the algorithm tree
read the pointer to the algorithm tree
Definition at line 804 of file CCommunicationHandler.cc.
References mAlgorithmTree.
00804 { 00805 return mAlgorithmTree; 00806 };
| void CCommunicationHandler::endConfiguration | ( | ) |
End the configuration i.e. make out of the algorithm structure a query processing structure.
| void CCommunicationHandler::clearParsingFinished | ( | ) |
Definition at line 616 of file CCommunicationHandler.cc.
References mParsingFinished.
Referenced by readAndParse().
00616 { 00617 mParsingFinished=false; 00618 };
| void CCommunicationHandler::setParsingFinished | ( | ) |
Definition at line 619 of file CCommunicationHandler.cc.
References mParsingFinished.
00619 { 00620 mParsingFinished=true; 00621 };
| bool CCommunicationHandler::isParsingFinished | ( | ) | const |
Definition at line 622 of file CCommunicationHandler.cc.
References mParsingFinished.
00622 { 00623 return mParsingFinished; 00624 };
| bool CCommunicationHandler::readAndParse | ( | ) |
Definition at line 627 of file CCommunicationHandler.cc.
References clearParsingFinished(), getPeerAddressString(), gGIFTHome, gMutex, CMutex::lock(), makeParser(), mDocumentRoot, mLog, mParser, mSocket, readChar(), and CMutex::unlock().
Referenced by main(), and processMessage().
00627 { 00628 gMutex->lock(); 00629 clearParsingFinished(); 00630 makeParser(); 00631 bool lSuccess=false; 00632 char lBuffer[20]; 00633 00634 string lLogString; 00635 00636 cerr << __FILE__ << ":" 00637 << __LINE__ << ":readAndParse before parse" << endl; 00638 00639 do { 00640 00641 00642 cout //<< "-" 00643 << flush; 00644 #ifdef _DEBUG 00645 #endif 00646 00647 //was asyncReadChar 00648 00649 if(readChar(mSocket, lBuffer)) { 00650 cout 00651 //<< "<" 00652 << lBuffer[0] 00653 //<< ">" 00654 << flush; 00655 #ifdef _DEBUG 00656 #endif 00657 lBuffer[1]=0; 00658 lLogString+=lBuffer; 00659 00660 if (!XML_Parse(mParser, 00661 lBuffer, 00662 1, 00663 false)) { 00664 cerr << "CCommunicationHandler.cc:" 00665 << __LINE__ 00666 << ": XML ERROR " 00667 << XML_ErrorString(XML_GetErrorCode(mParser)) 00668 << " at xml line " 00669 << XML_GetCurrentLineNumber(mParser) 00670 << endl; 00671 lSuccess=false; 00672 }else 00673 lSuccess=true;// i read at least one character 00674 }else{ 00675 cerr << "Stream broke down!" 00676 << XML_ErrorString(XML_GetErrorCode(mParser)) 00677 << " at line " 00678 << XML_GetCurrentLineNumber(mParser) 00679 << endl 00680 << "The cstdio stream was " << mSocket 00681 << endl; 00682 lSuccess=false; 00683 } 00684 } while (lSuccess && 00686 !(mDocumentRoot->isSubtreeFinished()) 00687 ); 00688 XML_Parse(mParser, 00689 lBuffer, 00690 0, 00691 true); 00692 00693 { 00694 ofstream lInLogFile((gGIFTHome 00695 + 00696 string("/gift-last-in-message.mrml")).c_str()); 00697 lInLogFile << endl 00698 << "<!-- The following message was sent by " << endl 00699 << this->getPeerAddressString() << endl; 00700 time_t lNow(time(0)); 00701 string lNowASCII=string(ctime(&lNow)); 00702 lInLogFile << "At: " << lNowASCII 00703 << " --> " << endl 00704 << lLogString 00705 << flush 00706 << endl; 00707 } 00708 00709 00710 if(lSuccess){ 00711 mLog << endl 00712 << "<!-- The following message was sent by " << endl 00713 << this->getPeerAddressString() << endl; 00714 time_t lNow(time(0)); 00715 string lNowASCII=string(ctime(&lNow)); 00716 mLog << "At: " << lNowASCII 00717 << " --> " << endl 00718 << lLogString 00719 << flush 00720 << endl; 00721 } 00722 00723 CXEVCommunication lVisitor(this); 00724 00725 gMutex->unlock(); 00726 00727 cerr << __FILE__ << ":" 00728 << __LINE__ << ":readAndParse before visit" << endl; 00729 mDocumentRoot->check(); 00730 cerr << __FILE__ << ":" 00731 << __LINE__ << ":readAndParse before check" << endl; 00732 mDocumentRoot->traverse(lVisitor); 00733 cerr << __FILE__ << ":" 00734 << __LINE__ << ":readAndParse after visit" << endl; 00735 00736 return lSuccess; 00737 }
| void CCommunicationHandler::makeParser | ( | ) |
Definition at line 740 of file CCommunicationHandler.cc.
References gMutex, CMutex::lock(), mDocumentRoot, mParser, newEndMRMLElement(), newMRMLTextElement(), newStartMRMLElement(), and CMutex::unlock().
Referenced by CCommunicationHandler(), and readAndParse().
00740 { 00741 gMutex->lock(); 00742 if(mParser) 00743 XML_ParserFree(mParser); 00744 mParser = XML_ParserCreate(NULL);//default encoding 00745 mDocumentRoot=new CXMLElement("__ROOT__",0); 00746 XML_SetUserData(mParser, 00747 mDocumentRoot);//ex this 00748 XML_SetElementHandler(mParser, 00749 newStartMRMLElement,//ex startMRMLElement 00750 newEndMRMLElement);//ex endMRMLElement 00751 XML_SetCharacterDataHandler(mParser, 00752 newMRMLTextElement); 00753 gMutex->unlock(); 00754 }
| void CCommunicationHandler::startMultiRequest | ( | const string & | inSessionID, | |
| const string & | inLanguageCode = "en" | |||
| ) |
If we process multiple queries which are part of one message, we have to first collect the answers from the requests, and then send the whole message.
startMultiRequest and endMultiRequest
are the functions which administer this process.
startMultiRequest clears the message which is going to be built and sets the language code
If we process multiple queries which are part of one message, we have to first collect the answers from the requests, and then send the whole message.
startMultiRequest and endMultiRequest
are the functions which administer this process.
startMultiRequest clears the message which is going to be built.
Definition at line 884 of file CCommunicationHandler.cc.
References addToMultiResponse(), CTimeStampGenerator::generateTimeStamp(), and mMultiResponse.
Referenced by CXEVCommunication::startVisit().
00885 { 00886 mMultiResponse=new CXMLElement("mrml",0); 00887 mMultiResponse->addAttribute("session-id", 00888 inSessionID); 00889 00890 CTimeStampGenerator lGenerator; 00891 addToMultiResponse(lGenerator.generateTimeStamp()); 00892 };
| void CCommunicationHandler::endMultiRequest | ( | ) |
sends the message which has been built
Definition at line 894 of file CCommunicationHandler.cc.
References addToMultiResponse(), CTimeStampGenerator::generateTimeStamp(), gMutex, CMutex::lock(), mLog, mMultiResponse, mSessionManager, mSocket, preamble(), sendMessage(), mrml_const::session_id, CSessionManager::translate(), and CMutex::unlock().
Referenced by CXEVCommunication::endVisit().
00894 { 00895 if(mMultiResponse){ 00896 string lMessage; 00897 00898 mMultiResponse->addAttribute("just-for-test", 00899 "and-of-course-for-fun"); 00900 CTimeStampGenerator lGenerator; 00901 addToMultiResponse(lGenerator.generateTimeStamp()); 00902 #warning FIXME add response translation here 00903 if(mMultiResponse->stringReadAttribute(mrml_const::session_id).first){ 00904 mSessionManager.translate(mMultiResponse->stringReadAttribute(mrml_const::session_id).second, 00905 *mMultiResponse); 00906 } 00907 00908 gMutex->lock(); 00909 mMultiResponse->toXML(lMessage); 00910 cout << "endMultiRequest: WRITING: " 00911 << lMessage 00912 << endl; 00913 00914 sendMessage(mSocket, 00915 preamble()+"\n"+lMessage+"\n", 00916 mLog); 00917 gMutex->unlock(); 00918 } 00919 };
| void CCommunicationHandler::addToMultiResponse | ( | CXMLElement * | inElement | ) |
adds an XMLElement to the multi-response which is built
adds an XMLElement to the multi-response which is built
Definition at line 923 of file CCommunicationHandler.cc.
References gMutex, CMutex::lock(), mMultiResponse, CXMLElement::toXML(), and CMutex::unlock().
Referenced by deleteSession(), endMultiRequest(), getAlgorithms(), getCollections(), getPropertySheet(), openSession(), renameSession(), sendRandomImages(), startMultiRequest(), and CXEVCommunication::startVisit().
00923 { 00924 gMutex->lock(); 00925 00926 if(0){ 00927 string lOutString; 00928 inElement->toXML(lOutString); 00929 cout << "CCommunicationHandler::addToMultiResponse: adding " 00930 << lOutString 00931 << endl; 00932 } 00933 00934 assert(mMultiResponse); 00935 if(inElement){ 00936 mMultiResponse->addChild(inElement); 00937 mMultiResponse->moveUp(); 00938 } 00939 gMutex->unlock(); 00940 };
| const string CCommunicationHandler::getCurrentSessionID | ( | ) |
returns the currently valid SessionID
Definition at line 963 of file CCommunicationHandler.cc.
References mMultiResponse, and mrml_const::session_id.
Referenced by CXEVCommunication::startVisit().
00963 { 00964 return mMultiResponse->stringReadAttribute(mrml_const::session_id).second; 00965 }
| CSessionManager & CCommunicationHandler::getSessionManager | ( | ) |
Using the session manager which is a member of this for other purposes
Definition at line 819 of file CCommunicationHandler.cc.
References mSessionManager.
Referenced by CXEVCommunication::startVisit().
00819 { 00820 return mSessionManager; 00821 }
| void CCommunicationHandler::incrementQueryAtRandomCount | ( | ) |
incrementing the QueryAtRandomCount flag
Definition at line 811 of file CCommunicationHandler.cc.
References mQueryAtRandomCount.
00811 { 00812 mQueryAtRandomCount++; 00813 }
| int CCommunicationHandler::getQueryAtRandomCount | ( | ) | const |
reading this flag
Definition at line 808 of file CCommunicationHandler.cc.
References mQueryAtRandomCount.
00808 { 00809 return mQueryAtRandomCount; 00810 }
| void CCommunicationHandler::setPeerAddressString | ( | string | inString | ) |
set the name of the peer, this is just an informative string, destined for the log.
The string can contain either the IP of the connecting computer, or else the peer credentials of the connecting tasks.
set the name of the peer, this is just an informative string, destined for the log.
The string can contain either the IP of the connecting computer, or else the peer credentials of the connecting tasks.
Definition at line 953 of file CCommunicationHandler.cc.
References gMutex, CMutex::lock(), mPeerAddressString, and CMutex::unlock().
Referenced by processMessage().
00953 { 00954 gMutex->lock(); 00955 mPeerAddressString=inString; 00956 gMutex->unlock(); 00957 };
| const string & CCommunicationHandler::getPeerAddressString | ( | ) | const |
get the Peer adress string
Definition at line 959 of file CCommunicationHandler.cc.
References mPeerAddressString.
Referenced by readAndParse().
00959 { 00960 return mPeerAddressString; 00961 }