// ABCSHandlers.cpp: implementation of the ABCSHandlers class. // ////////////////////////////////////////////////////////////////////// #include "ABCCommon.h" #include "ABCSHandlers.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// ABCSHandlers::ABCSHandlers() : m_bVoteToAccept(true) { } ABCSHandlers::~ABCSHandlers() { } rtr_status_t ABCSHandlers::OnInitialize( RTRApplicationMessage *pRTRData, RTRServerTransactionController *pController ) { cout << endl << endl << endl << "New Transaction being received..." << endl; m_bVoteToAccept = true; return RTR_STS_OK; } rtr_status_t ABCSHandlers::OnPrepareTransaction( RTRMessage *pRTRMessage, RTRServerTransactionController *pController ) { /* We simply check to see if anything has gone wrong. If so, reject the transaction, otherwise accept it. */ rtr_status_t sStatus; if (true == m_bVoteToAccept) { cout << "Voting to Accept..." << endl; sStatus = pController->AcceptTransaction(); } else { cout << "Voting to Reject..." << endl; sStatus = pController->RejectTransaction(); } return sStatus; } rtr_status_t ABCSHandlers::OnAccepted( RTRMessage *pRTRMessage, RTRServerTransactionController *pController) { cout << "Entire Transaction Accepted..." << endl; return RTRServerMessageHandler::OnAccepted(pRTRMessage,pController); } rtr_status_t ABCSHandlers::OnRejected( RTRMessage *pRTRMessage, RTRServerTransactionController *pController) { cout << "Entire Transaction Rejected..." << endl; return RTRServerMessageHandler::OnRejected(pRTRMessage,pController); } void ABCSHandlers::OnABCOrderNotProcessed() { m_bVoteToAccept = false; return; }