Engine::Session* Engine::FixEngine::createSession(Engine::Application* apApp, const std::string& aSenderCompID, const std::string& aTargetCompID, Engine::FIXVersion aVer = FIX42, Engine::SessionExtraParameters* pParam = NULL, const Engine::MessageStorageType storageType = persistent_storageType)
After session is created use void Engine::Session::connect() to connect it as acceptor.
For example:
#include <iostream> #include <B2BITS_V12.h> using namespace std; class Appl : public Engine::Application { // See "Application description" section }; try { // initialization Engine::FixEngine::init(); Appl appl; // create a session for FIX 4.2 Engine::Session* pSn = Engine::FixEngine::singleton()->createSession( &appl, "SENDER", "TARGET", Engine::FIX42); // establish the session as Acceptor pSn->connect(); // ... - business logic // terminate the FIX session pSn->disconnect(); // it is vital to do this before the 'release' call pSn->registerApplication(NULL); // release resources pSn->release(); FixEngine::destroy(); } catch(const Exception& ex) { cout << "EXCEPTION: " << ex.what() << endl; }
Engine::Session::disconnect(bool aMarkAsTerminated = true)
Engine::Session::disconnect(const std::string &aLogoutText, bool aMarkAsTerminated=true)
aMarkAsTerminated parameter is used to set the desired state after disconnection. If it is set to "true" acceptor tries to disconnect gracefully (i.e. execute logout procedure). If it is set to "false" accettor moves to the non-gracefully terminated state.
It is vital to call Engine::Session::registerApplication(NULL) before calling the release method.
It is vital to call the Engine::Session::release() method only once for the given session.
All session level messages are send automatically when needed.
1.5.6