fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::SessionInstance< T > Class Template Reference

Server session instance. More...

#include <sessionwrapper.hpp>

Inheritance diagram for FIX8::SessionInstance< T >:
FIX8::SessionInstanceBase

Public Types

using SessionInstance_ptr = std::unique_ptr< SessionInstance< T >>
 Convenient scoped pointer for your session instance. More...
 

Public Member Functions

 SessionInstance (ServerSession< T > &sf)
 Ctor. Prepares session instance with inbound connection. More...
 
virtual ~SessionInstance ()
 Dtor. More...
 
virtual T * session_ptr () override
 
virtual void start (bool wait, unsigned send_seqnum=0, unsigned recv_seqnum=0) override
 
virtual void stop () override
 Stop the session. Cleanup. More...
 
- Public Member Functions inherited from FIX8::SessionInstanceBase
 SessionInstanceBase ()=default
 Ctor. Prepares session instance with inbound connection. More...
 
virtual ~SessionInstanceBase ()
 Dtor. More...
 

Private Attributes

ServerSession< T > & _sf
 
Poco::Net::SocketAddress _claddr
 
Poco::Net::StreamSocket * _sock
 
T * _session
 
ServerConnection_psc
 

Detailed Description

template<typename T>
class FIX8::SessionInstance< T >

Server session instance.

Template Parameters
Tspecialised with your derived session class

Definition at line 496 of file sessionwrapper.hpp.

Member Typedef Documentation

template<typename T >
using FIX8::SessionInstance< T >::SessionInstance_ptr = std::unique_ptr<SessionInstance<T>>

Convenient scoped pointer for your session instance.

Definition at line 724 of file sessionwrapper.hpp.

Constructor & Destructor Documentation

template<typename T >
FIX8::SessionInstance< T >::SessionInstance ( ServerSession< T > &  sf)
inline

Ctor. Prepares session instance with inbound connection.

Definition at line 629 of file sessionwrapper.hpp.

References FIX8::SessionConfig::_loginParameters.

629  :
630  _sf(sf),
631  _sock(new Poco::Net::StreamSocket(_sf.accept(_claddr))),
632  _session(new T(_sf._ctx, _sf.get_sender_comp_id(_sf._ses))),
633  _psc(new ServerConnection(_sock, _claddr, *_session, _sf.get_heartbeat_interval(_sf._ses), _sf.get_process_model(_sf._ses),
634  _sf.get_tcp_nodelay(_sf._ses), _sf.get_tcp_reuseaddr(_sf._ses), _sf.get_tcp_linger(_sf._ses),
635  _sf.get_tcp_keepalive(_sf._ses),
636 #ifdef FIX8_HAVE_OPENSSL
637  _sf.is_secure()
638 #else
639  false
640 #endif
641  ))
642  {
643  _session->set_login_parameters(_sf._loginParameters);
644  _session->set_session_config(&_sf);
645  }
ServerSession< T > & _sf
ServerConnection * _psc
Poco::Net::StreamSocket * _sock
Poco::Net::SocketAddress _claddr
template<typename T >
virtual FIX8::SessionInstance< T >::~SessionInstance ( )
inlinevirtual

Dtor.

Definition at line 648 of file sessionwrapper.hpp.

References FIX8::SessionInstance< T >::_psc, FIX8::SessionInstance< T >::_session, FIX8::SessionInstance< T >::_sock, FIX8::Logger::Error, FIX8::Connection::stop(), and FIX8::f8Exception::what().

649  {
650  try
651  {
652  if (_psc != nullptr)
653  {
654  _psc->stop();
655  delete _psc;
656  _psc = nullptr;
657  }
658  }
659  catch (f8Exception& e)
660  {
661  this->_session->log(e.what(), Logger::Error);
662  }
663  catch (Poco::Exception& e)
664  {
665  this->_session->log(e.what(), Logger::Error);
666  }
667  catch (std::exception& e)
668  {
669  this->_session->log(e.what(), Logger::Error);
670  }
671 
672  try
673  {
674  delete _session;
675  _session = nullptr;
676  }
677  catch (f8Exception& e)
678  {
679  this->_session->log(e.what(), Logger::Error);
680  }
681  catch (Poco::Exception& e)
682  {
683  this->_session->log(e.what(), Logger::Error);
684  }
685  catch (std::exception& e)
686  {
687  this->_session->log(e.what(), Logger::Error);
688  }
689 
690  try
691  {
692  delete _sock;
693  _sock = nullptr;
694  }
695  catch (f8Exception& e)
696  {
697  this->_session->log(e.what(), Logger::Error);
698  }
699  catch (Poco::Exception& e)
700  {
701  this->_session->log(e.what(), Logger::Error);
702  }
703  catch (std::exception& e)
704  {
705  this->_session->log(e.what(), Logger::Error);
706  }
707  }
F8API void stop()
Stop the reader and writer threads.
Definition: connection.cpp:322
ServerConnection * _psc
Poco::Net::StreamSocket * _sock

Member Function Documentation

template<typename T >
virtual T* FIX8::SessionInstance< T >::session_ptr ( )
inlineoverridevirtual

Get a pointer to the session

Returns
the session pointer

Implements FIX8::SessionInstanceBase.

Definition at line 711 of file sessionwrapper.hpp.

References FIX8::SessionInstance< T >::_session.

711 { return _session; }
template<typename T >
virtual void FIX8::SessionInstance< T >::start ( bool  wait,
unsigned  send_seqnum = 0,
unsigned  recv_seqnum = 0 
)
inlineoverridevirtual

Start the session - accept the connection, logon and start heartbeating.

Parameters
waitif true wait till session finishes before returning
send_seqnumif supplied, override the send login sequence number, set next send to seqnum+1
recv_seqnumif supplied, override the receive login sequence number, set next recv to seqnum+1

Reimplemented from FIX8::SessionInstanceBase.

Definition at line 717 of file sessionwrapper.hpp.

718  { _session->start(_psc, wait, send_seqnum, recv_seqnum); }
ServerConnection * _psc
template<typename T >
virtual void FIX8::SessionInstance< T >::stop ( )
inlineoverridevirtual

Stop the session. Cleanup.

Reimplemented from FIX8::SessionInstanceBase.

Definition at line 721 of file sessionwrapper.hpp.

721 { _session->stop(); }

Member Data Documentation

template<typename T >
Poco::Net::SocketAddress FIX8::SessionInstance< T >::_claddr
private

Definition at line 622 of file sessionwrapper.hpp.

template<typename T >
ServerConnection* FIX8::SessionInstance< T >::_psc
private

Definition at line 625 of file sessionwrapper.hpp.

Referenced by FIX8::SessionInstance< T >::~SessionInstance().

template<typename T >
T* FIX8::SessionInstance< T >::_session
private
template<typename T >
ServerSession<T>& FIX8::SessionInstance< T >::_sf
private

Definition at line 621 of file sessionwrapper.hpp.

template<typename T >
Poco::Net::StreamSocket* FIX8::SessionInstance< T >::_sock
private

Definition at line 623 of file sessionwrapper.hpp.

Referenced by FIX8::SessionInstance< T >::~SessionInstance().


The documentation for this class was generated from the following file: