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

Client wrapper. More...

#include <sessionwrapper.hpp>

Inheritance diagram for FIX8::ClientSession< T >:
FIX8::ClientSessionBase FIX8::SessionConfig FIX8::Configuration FIX8::ReliableClientSession< T >

Public Types

using ClientSession_ptr = std::unique_ptr< ClientSession< T >>
 Convenient scoped pointer for your session. More...
 
using session_type = T
 
- Public Types inherited from FIX8::Configuration
enum  group_types {
  g_sessions, g_persisters, g_loggers, g_server_group,
  g_ssl_context, g_schedules, g_logins, g_client_group,
  g_count
}
 
enum  Logtype { session_log, protocol_log }
 

Public Member Functions

 ClientSession (const F8MetaCntx &ctx, const std::string &conf_file, const std::string &session_name, bool init_con_later=false)
 Ctor. Prepares session for connection as an initiator. More...
 
virtual ~ClientSession ()
 Dtor. More...
 
T * session_ptr ()
 
virtual void start (bool wait, unsigned send_seqnum=0, unsigned recv_seqnum=0, const f8String davi=f8String())
 
- Public Member Functions inherited from FIX8::ClientSessionBase
 ClientSessionBase (const F8MetaCntx &ctx, const std::string &conf_file, const std::string &session_name)
 
virtual bool has_given_up () const
 
virtual ~ClientSessionBase ()
 Dtor. More...
 
- Public Member Functions inherited from FIX8::SessionConfig
 SessionConfig (const F8MetaCntx &ctx, const std::string &conf_file, const std::string &session_name)
 Ctor. Loads configuration, obtains session details, sets up logfile flags. More...
 
virtual ~SessionConfig ()
 Dtor. More...
 
const XmlElementget_session_element () const
 
- Public Member Functions inherited from FIX8::Configuration
const XmlElementfind_group (group_types type, const std::string &tag) const
 
 Configuration (const std::string &xmlfile, bool do_process=false)
 
 Configuration (std::istream &istr, bool do_process=false)
 
virtual ~Configuration ()
 Dtor. More...
 
F8API int process ()
 
const XmlElementget_session (const unsigned num) const
 
F8API Connection::Role get_role (const XmlElement *from) const
 
F8API size_t get_addresses (const XmlElement *from, std::vector< Server > &target) const
 
F8API Poco::Net::SocketAddress get_address (const XmlElement *from) const
 
F8API Poco::Net::IPAddress get_ip (const XmlElement *from) const
 
template<typename T >
get_logflags (const std::string &tag, const std::vector< std::string > &names, const XmlElement *from, Logger::LogPositions *positions=nullptr) const
 
F8API std::string & get_logname (const XmlElement *from, std::string &to, const SessionID *sid=nullptr) const
 
unsigned get_connect_timeout (const XmlElement *from, const unsigned def=defaults::connect_timeout) const
 
unsigned get_retry_interval (const XmlElement *from, const unsigned def=defaults::retry_interval) const
 
unsigned get_retry_count (const XmlElement *from, const int def=defaults::login_retries) const
 
unsigned get_tcp_recvbuf_sz (const XmlElement *from, const unsigned def=0) const
 
unsigned get_tcp_sendbuf_sz (const XmlElement *from, const unsigned def=0) const
 
unsigned get_version (const XmlElement *from, const unsigned def=0) const
 
unsigned get_tabsize (const XmlElement *from, const unsigned def=defaults::tabsize) const
 
unsigned get_logfile_rotation (const XmlElement *from, const unsigned def=defaults::log_rotation) const
 
unsigned get_heartbeat_interval (const XmlElement *from, const unsigned def=defaults::hb_interval) const
 
bool get_tcp_nodelay (const XmlElement *from, const bool def=true) const
 
bool get_tcp_keepalive (const XmlElement *from, const bool def=false) const
 
bool get_tcp_reuseaddr (const XmlElement *from, const bool def=false) const
 
int get_tcp_linger (const XmlElement *from, const int def=-1) const
 
bool get_silent_disconnect (const XmlElement *from, const bool def=false) const
 
bool get_enforce_compids_flag (const XmlElement *from, const bool def=true) const
 
bool get_ignore_logon_sequence_check_flag (const XmlElement *from, const bool def=false) const
 
bool get_no_chksum_flag (const XmlElement *from, const bool def=false) const
 
bool get_permissive_mode_flag (const XmlElement *from, const bool def=false) const
 
bool get_reset_sequence_number_flag (const XmlElement *from, const bool def=false) const
 
bool get_always_seqnum_assign (const XmlElement *from, const bool def=false) const
 
F8API ProcessModel get_process_model (const XmlElement *from) const
 
default_appl_ver_id get_default_appl_ver_id (const XmlElement *from) const
 
sender_comp_id get_sender_comp_id (const XmlElement *from) const
 
target_comp_id get_target_comp_id (const XmlElement *from) const
 
F8API Persistercreate_persister (const XmlElement *from, const SessionID *sid=nullptr, bool flag=false) const
 
F8API Loggercreate_logger (const XmlElement *from, const Logtype ltype, const SessionID *sid=nullptr) const
 
F8API Schedule create_schedule (const XmlElement *from) const
 
F8API Clients create_clients (const XmlElement *from) const
 
F8API Schedule create_login_schedule (const XmlElement *from) const
 
F8API Session_Schedulecreate_session_schedule (const XmlElement *from) const
 
F8API unsigned get_all_sessions (std::vector< const XmlElement * > &target, const Connection::Role role=Connection::cn_unknown) const
 
const XmlElementget_root () const
 
template<typename T >
get_logflags (const string &tag, const vector< string > &names, const XmlElement *from, Logger::LogPositions *positions) const
 

Protected Attributes

sender_comp_id _sci
 
target_comp_id _tci
 
const SessionID _id
 
Logger_log
 
Logger_plog
 
Persister_persist
 
T * _session
 
Poco::Net::StreamSocket * _sock = nullptr
 
Poco::Net::SocketAddress _addr
 
ClientConnection_cc = nullptr
 

Additional Inherited Members

- Public Attributes inherited from FIX8::SessionConfig
const F8MetaCntx_ctx
 
const XmlElement_ses
 
LoginParameters _loginParameters
 
const std::string _session_name
 
- Protected Member Functions inherited from FIX8::Configuration
bool from_or_default (const XmlElement *from, const f8String &tag, f8String &target) const
 
template<typename T >
T & get_string_field (const XmlElement *from, const std::string &tag, T &to) const
 
Tickval::ticks get_time_field (const XmlElement *from, const std::string &tag, bool timeonly=false) const
 
template<typename T >
find_or_default (const XmlElement *from, const std::string &tag, const T def) const
 

Detailed Description

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

Client wrapper.

Template Parameters
Tspecialised with your derived session class

Definition at line 198 of file sessionwrapper.hpp.

Member Typedef Documentation

template<typename T >
using FIX8::ClientSession< T >::ClientSession_ptr = std::unique_ptr<ClientSession<T>>

Convenient scoped pointer for your session.

Definition at line 274 of file sessionwrapper.hpp.

template<typename T >
using FIX8::ClientSession< T >::session_type = T

Definition at line 276 of file sessionwrapper.hpp.

Constructor & Destructor Documentation

template<typename T >
FIX8::ClientSession< T >::ClientSession ( const F8MetaCntx ctx,
const std::string &  conf_file,
const std::string &  session_name,
bool  init_con_later = false 
)
inline

Ctor. Prepares session for connection as an initiator.

Definition at line 216 of file sessionwrapper.hpp.

References FIX8::LoginParameters::_hb_int, FIX8::SessionConfig::_loginParameters, FIX8::SessionConfig::_ses, and FIX8::Configuration::get_process_model().

217  :
218  ClientSessionBase(ctx, conf_file, session_name),
224  _session(new T(_ctx, _id, _persist, _log, _plog)),
226 #ifdef FIX8_HAVE_OPENSSL
227  ,_ssl(get_ssl_context(_ses), true)
228 #endif
229  {
230  if (!init_con_later)
231  {
232 #ifdef FIX8_HAVE_OPENSSL
233  bool secured(_ssl.is_secure());
234  _sock = secured
235  ? new Poco::Net::SecureStreamSocket(_ssl._context)
236  : new Poco::Net::StreamSocket;
237 #else
238  bool secured(false);
239  _sock = new Poco::Net::StreamSocket;
240 #endif
241  _cc = new ClientConnection(_sock, _addr, *_session, this->_loginParameters._hb_int, get_process_model(_ses), true, secured);
242  }
243 
244  _session->set_login_parameters(this->_loginParameters);
245  _session->set_session_config(this);
246  }
LoginParameters _loginParameters
const SessionID _id
F8API Poco::Net::SocketAddress get_address(const XmlElement *from) const
F8API Persister * create_persister(const XmlElement *from, const SessionID *sid=nullptr, bool flag=false) const
const f8String _beginStr
Fix header beginstring.
Definition: message.hpp:228
Poco::Net::StreamSocket * _sock
const F8MetaCntx & ctx()
Compiler generated metadata object, accessed through this function.
ClientConnection * _cc
const F8MetaCntx & _ctx
sender_comp_id get_sender_comp_id(const XmlElement *from) const
ClientSessionBase(const F8MetaCntx &ctx, const std::string &conf_file, const std::string &session_name)
const XmlElement * _ses
Poco::Net::SocketAddress _addr
F8API Logger * create_logger(const XmlElement *from, const Logtype ltype, const SessionID *sid=nullptr) const
target_comp_id get_target_comp_id(const XmlElement *from) const
F8API ProcessModel get_process_model(const XmlElement *from) const
template<typename T >
virtual FIX8::ClientSession< T >::~ClientSession ( )
inlinevirtual

Dtor.

Definition at line 249 of file sessionwrapper.hpp.

References FIX8::ClientSession< T >::_log, FIX8::ClientSession< T >::_persist, FIX8::ClientSession< T >::_plog, and FIX8::ClientSession< T >::_session.

250  {
251  delete _persist;
252  _persist = nullptr;
253  delete _session;
254  _session = nullptr;
255  delete _log;
256  _log = nullptr;
257  delete _plog;
258  _plog = nullptr;
259  }

Member Function Documentation

template<typename T >
T* FIX8::ClientSession< T >::session_ptr ( )
inlinevirtual

Get a pointer to the session

Returns
the session pointer

Implements FIX8::ClientSessionBase.

Definition at line 263 of file sessionwrapper.hpp.

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

263 { return _session; }
template<typename T >
virtual void FIX8::ClientSession< T >::start ( bool  wait,
unsigned  send_seqnum = 0,
unsigned  recv_seqnum = 0,
const f8String  davi = f8String() 
)
inlinevirtual

Start the session - initiate 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
davidefault appl version id (FIXT)

Implements FIX8::ClientSessionBase.

Reimplemented in FIX8::ReliableClientSession< T >.

Definition at line 270 of file sessionwrapper.hpp.

271  { _session->start(_cc, wait, send_seqnum, recv_seqnum, davi); }
ClientConnection * _cc

Member Data Documentation

template<typename T >
Poco::Net::SocketAddress FIX8::ClientSession< T >::_addr
protected

Definition at line 208 of file sessionwrapper.hpp.

template<typename T >
ClientConnection* FIX8::ClientSession< T >::_cc = nullptr
protected

Definition at line 209 of file sessionwrapper.hpp.

Referenced by FIX8::ReliableClientSession< T >::operator()().

template<typename T >
const SessionID FIX8::ClientSession< T >::_id
protected

Definition at line 203 of file sessionwrapper.hpp.

template<typename T >
Logger* FIX8::ClientSession< T >::_log
protected

Definition at line 204 of file sessionwrapper.hpp.

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

template<typename T >
Persister* FIX8::ClientSession< T >::_persist
protected

Definition at line 205 of file sessionwrapper.hpp.

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

template<typename T >
Logger * FIX8::ClientSession< T >::_plog
protected

Definition at line 204 of file sessionwrapper.hpp.

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

template<typename T >
sender_comp_id FIX8::ClientSession< T >::_sci
protected

Definition at line 201 of file sessionwrapper.hpp.

template<typename T >
T* FIX8::ClientSession< T >::_session
protected
template<typename T >
Poco::Net::StreamSocket* FIX8::ClientSession< T >::_sock = nullptr
protected

Definition at line 207 of file sessionwrapper.hpp.

Referenced by FIX8::ReliableClientSession< T >::operator()().

template<typename T >
target_comp_id FIX8::ClientSession< T >::_tci
protected

Definition at line 202 of file sessionwrapper.hpp.


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