void Application::onMessage( const FIX50SP2::ApplicationMessageRequest& message, const FIX::SessionID& sessionID ) { FIX50SP2::ExecutionReport executionReport; try { FIX::Session *pSession = FIX::Session::lookupSession(sessionID); FIX::UtcTimeStamp startTime; std::cout << "Session( " << sessionID << ").onMessage ( order): " << " PossibleLongCallback= " << pSession->getPossibleBusyWaitInCalbacks() << std::endl; std::cout << "Start time = " << FIX::UtcTimeStampConvertor::convert(startTime, true) << std::endl; while (!timedOut(startTime, m_expectedDownloadLatency)) { usleep(500000); executionReport.set( FIX::ExecID(genExecID()) ); FIX::Session::sendToTarget( executionReport, sessionID ); } FIX::UtcTimeStamp endTime; std::cout << "End time = " << FIX::UtcTimeStampConvertor::convert(endTime, true) << std::endl; } catch ( std::exception& ex) { std::cout << "ApplicationMessageRequest handling failed: " << ex.what() << std::endl; } }
THREAD_PROC ThreadedSSLSocketInitiator::socketThread(void *p) { ThreadPair *pair = reinterpret_cast< ThreadPair * >(p); ThreadedSSLSocketInitiator *pInitiator = pair->first; ThreadedSSLSocketConnection *pConnection = pair->second; FIX::SessionID sessionID = pConnection->getSession()->getSessionID(); FIX::Session *pSession = FIX::Session::lookupSession(sessionID); int socket = pConnection->getSocket(); delete pair; pInitiator->lock(); if (!pConnection->connect()) { pInitiator->getLog()->onEvent("Connection failed"); pConnection->disconnect(); SSL *ssl = pConnection->sslObject(); delete pConnection; pInitiator->removeThread(SocketKey(socket, ssl)); pInitiator->setDisconnected(sessionID); return 0; } // Do the SSL handshake. int rc = SSL_connect(pConnection->sslObject()); if (rc <= 0) { int err = SSL_get_error(pConnection->sslObject(), rc); pInitiator->getLog()->onEvent("SSL_connect failed with SSL error " + IntConvertor::convert(err)); pConnection->disconnect(); SSL *ssl = pConnection->sslObject(); delete pConnection; pInitiator->removeThread(SocketKey(socket, ssl)); pInitiator->setDisconnected(sessionID); return 0; } pInitiator->setConnected(sessionID); pInitiator->getLog()->onEvent("Connection succeeded"); pSession->next(); while (pConnection->read()) { } SSL *ssl = pConnection->sslObject(); delete pConnection; if (!pInitiator->isStopped()) pInitiator->removeThread(SocketKey(socket, ssl)); pInitiator->setDisconnected(sessionID); return 0; }
THREAD_PROC ThreadedSocketInitiator::socketThread( void* p ) { ThreadPair * pair = reinterpret_cast < ThreadPair* > ( p ); ThreadedSocketInitiator* pInitiator = pair->first; ThreadedSocketConnection* pConnection = pair->second; FIX::SessionID sessionID = pConnection->getSession()->getSessionID(); FIX::Session* pSession = FIX::Session::lookupSession( sessionID ); int socket = pConnection->getSocket(); delete pair; pInitiator->lock(); if( !pConnection->connect() ) { pInitiator->getLog()->onEvent( "Connection failed" ); pConnection->disconnect(); delete pConnection; pInitiator->removeThread( socket ); pInitiator->setDisconnected( sessionID ); return 0; } pInitiator->setConnected( sessionID ); pInitiator->getLog()->onEvent( "Connection succeeded" ); pSession->next(); while ( pConnection->read() ) {} delete pConnection; if( !pInitiator->isStopped() ) pInitiator->removeThread( socket ); pInitiator->setDisconnected( sessionID ); return 0; }