fix8  version 1.4.0
Open Source C++ FIX Framework
myfix_session_server Class Reference

Example server session. Derives from FIX8::Session. More...

#include <myfix.hpp>

Inheritance diagram for myfix_session_server:
FIX8::Session

Public Member Functions

 myfix_session_server (const FIX8::F8MetaCntx &ctx, const FIX8::sender_comp_id &sci, FIX8::Persister *persist=nullptr, FIX8::Logger *logger=nullptr, FIX8::Logger *plogger=nullptr)
 
bool handle_application (const unsigned seqnum, const FIX8::Message *&msg)
 
bool sample_scheduler_callback ()
 
void state_change (const FIX8::States::SessionStates before, const FIX8::States::SessionStates after)
 
- Public Member Functions inherited from FIX8::Session
F8API Session (const F8MetaCntx &ctx, const SessionID &sid, Persister *persist=nullptr, Logger *logger=nullptr, Logger *plogger=nullptr)
 
F8API Session (const F8MetaCntx &ctx, const sender_comp_id &sci=sender_comp_id(), Persister *persist=nullptr, Logger *logger=nullptr, Logger *plogger=nullptr)
 
virtual F8API ~Session ()
 Dtor. More...
 
F8API int start (Connection *connection, bool wait=true, const unsigned send_seqnum=0, const unsigned recv_seqnum=0, const f8String davi=f8String())
 
void clear_connection (const Connection *connection)
 
virtual F8API bool process (const f8String &from)
 
virtual F8API bool retrans_callback (const SequencePair &with, RetransmissionContext &rctx)
 
virtual F8API bool send (Message *msg, bool destroy=true, const unsigned custom_seqnum=0, const bool no_increment=false)
 
virtual F8API bool send (Message &msg, const unsigned custom_seqnum=0, const bool no_increment=false)
 
virtual F8API size_t send_batch (const std::vector< Message * > &msgs, bool destroy=true)
 
F8API bool send_process (Message *msg)
 
virtual F8API int modify_header (MessageBase *msg)
 
F8API void update_persist_seqnums ()
 Force persister to sync next send/receive seqnums. More...
 
F8API void stop ()
 stop the session. More...
 
Connectionget_connection ()
 
Timer< Session > & get_timer ()
 
const F8MetaCntxget_ctx () const
 
bool is_loggable (Logger::Level level) const
 
bool enqueue (const std::string &what, Logger::Level lev, const char *fl=nullptr, unsigned value=0) const
 
bool log (const std::string &what, Logger::Level lev, const char *fl=nullptr, unsigned value=0) const
 
bool plog (const std::string &what, Logger::Level lev, const unsigned direction=0) const
 
const Tickvalget_last_received () const
 
const Tickvalget_last_sent () const
 
void update_sent ()
 Update the last sent time. More...
 
void update_received ()
 Update the last received time. More...
 
F8API void compid_check (const unsigned seqnum, const Message *msg, const SessionID &id) const
 
F8API bool sequence_check (const unsigned seqnum, const Message *msg)
 
virtual bool activation_check (const unsigned seqnum, const Message *msg)
 
F8API bool enforce (const unsigned seqnum, const Message *msg)
 
const SessionIDget_sid () const
 
unsigned get_next_send_seq () const
 
void set_login_parameters (const LoginParameters &loginParamaters)
 
void get_login_parameters (LoginParameters &loginParamaters) const
 
const LoginParametersget_login_parameters () const
 
void set_reset_sequence_numbers_flag (bool flag)
 
void set_persister (Persister *pst)
 
Controlcontrol ()
 
bool is_shutdown ()
 
void set_session_config (struct SessionConfig *sf)
 
virtual F8API Messagegenerate_logout (const char *msgstr=nullptr)
 
virtual F8API Messagegenerate_heartbeat (const f8String &testReqID)
 
virtual F8API Messagegenerate_resend_request (const unsigned begin, const unsigned end=0)
 
virtual F8API Messagegenerate_sequence_reset (const unsigned newseqnum, const bool gapfillflag=false)
 
virtual F8API Messagegenerate_test_request (const f8String &testReqID)
 
virtual F8API Messagegenerate_reject (const unsigned seqnum, const char *what, const char *msgtype=nullptr)
 
virtual F8API Messagegenerate_business_reject (const unsigned seqnum, const Message *msg, const int reason, const char *what)
 
void do_state_change (const States::SessionStates new_state)
 
States::SessionStates get_session_state () const
 

Private Attributes

tex_router_server _router
 

Additional Inherited Members

- Public Types inherited from FIX8::Session
enum  SessionControl {
  shutdown, print, printnohb, debug,
  count
}
 
using Control = ebitset_r< SessionControl >
 
using SequencePair = std::pair< const unsigned, const f8String >
 
- Static Public Member Functions inherited from FIX8::Session
static const Messagedetach (const Message *&msg)
 
static const f8Stringget_session_state_string (const States::SessionStates state)
 
static F8API const f8String copyright_string ()
 
- Protected Member Functions inherited from FIX8::Session
F8API bool heartbeat_service ()
 Heartbeat generation service thread method. More...
 
F8API bool activation_service ()
 Session start/stop service thread method. More...
 
virtual F8API bool handle_logon (const unsigned seqnum, const Message *msg)
 
virtual F8API Messagegenerate_logon (const unsigned heartbeat_interval, const f8String davi=f8String())
 
virtual F8API bool handle_logout (const unsigned seqnum, const Message *msg)
 
virtual F8API bool handle_heartbeat (const unsigned seqnum, const Message *msg)
 
virtual F8API bool handle_resend_request (const unsigned seqnum, const Message *msg)
 
virtual F8API bool handle_sequence_reset (const unsigned seqnum, const Message *msg)
 
virtual F8API bool handle_test_request (const unsigned seqnum, const Message *msg)
 
virtual bool handle_reject (const unsigned seqnum, const Message *msg)
 
virtual bool handle_admin (const unsigned seqnum, const Message *msg)
 
virtual F8API bool handle_outbound_reject (const unsigned seqnum, const Message *msg, const char *errstr)
 
virtual void modify_outbound (Message *msg)
 
virtual bool authenticate (SessionID &id, const Message *msg)
 
virtual F8API void recover_seqnums ()
 Recover next expected and next to send sequence numbers from persitence layer. More...
 
Messagecreate_msg (const f8String &msg_type) const
 
void set_scheduler (int priority)
 
void set_affinity (int core_id)
 
- Protected Attributes inherited from FIX8::Session
Control _control
 
f8_atomic< unsigned > _next_send_seq
 
f8_atomic< unsigned > _next_receive_seq
 
f8_atomic< States::SessionStates_state
 
f8_atomic< bool > _active
 
Tickval _last_sent
 
Tickval _last_received
 
const F8MetaCntx_ctx
 
sender_comp_id _sci
 
Connection_connection
 
unsigned _req_next_send_seq
 
unsigned _req_next_receive_seq
 
SessionID _sid
 
struct SessionConfig_sf
 
LoginParameters _loginParameters
 
f8_spin_lock _per_spl
 
Persister_persist
 
Logger_logger
 
Logger_plogger
 
Timer< Session_timer
 
TimerEvent< Session_hb_processor
 
TimerEvent< Session_session_scheduler
 
std::string _batchmsgs_buffer
 
Session_Schedule_schedule
 
- Static Protected Attributes inherited from FIX8::Session
static F8API const std::vector< f8String_state_names
 string representation of Sessionstates More...
 

Detailed Description

Example server session. Derives from FIX8::Session.

Your application must define a class similar to this in order to receive client connections. You must also implement handle_application in order to receive application messages from the framework.

Definition at line 116 of file myfix.hpp.

Constructor & Destructor Documentation

myfix_session_server::myfix_session_server ( const FIX8::F8MetaCntx ctx,
const FIX8::sender_comp_id sci,
FIX8::Persister persist = nullptr,
FIX8::Logger logger = nullptr,
FIX8::Logger plogger = nullptr 
)
inline

Ctor. Acceptor.

Parameters
ctxreference to generated metadata
scisender comp id of hosting session
persistpersister for this session
loggerlogger for this session
ploggerprotocol logger for this session

Definition at line 127 of file myfix.hpp.

128  : Session(ctx, sci, persist, logger, plogger),
129  _router(*this) {}
tex_router_server _router
Definition: myfix.hpp:118
F8API Session(const F8MetaCntx &ctx, const SessionID &sid, Persister *persist=nullptr, Logger *logger=nullptr, Logger *plogger=nullptr)
Definition: session.cpp:105

Member Function Documentation

bool myfix_session_server::handle_application ( const unsigned  seqnum,
const FIX8::Message *&  msg 
)
virtual

Application message callback. This method is called by the framework when an application message has been received and decoded. You should implement this method and call the supplied Message::process.

Parameters
seqnumFix sequence number of the message
msgMesage decoded (base ptr)
Returns
true on success

Implements FIX8::Session.

Definition at line 333 of file harness.cpp.

References FIX8::Message::process().

334 {
335  return enforce(seqnum, msg) || msg->process(_router);
336 }
tex_router_server _router
Definition: myfix.hpp:118
virtual bool process(Router &rt) const
Definition: message.hpp:1147
F8API bool enforce(const unsigned seqnum, const Message *msg)
Definition: session.cpp:252
bool myfix_session_server::sample_scheduler_callback ( )

example scheduler callback function

Returns
true if ok

Definition at line 447 of file myfix.cpp.

Referenced by server_process().

448 {
449  cout << "myfix_session_server::sample_scheduler_callback Hello!" << endl;
450  return true;
451 }
void myfix_session_server::state_change ( const FIX8::States::SessionStates  before,
const FIX8::States::SessionStates  after 
)
virtual

This method id called whenever a session state change occurs

Parameters
beforeprevious session state
afternew session state

Reimplemented from FIX8::Session.

Definition at line 339 of file harness.cpp.

340 {
341  cout << get_session_state_string(before) << " => " << get_session_state_string(after) << endl;
342 }
static const f8String & get_session_state_string(const States::SessionStates state)
Definition: session.hpp:853

Member Data Documentation

tex_router_server myfix_session_server::_router
private

Definition at line 118 of file myfix.hpp.


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