fix8
version 1.4.0
Open Source C++ FIX Framework
|
Fix8 Base Session. User sessions are derived from this class. More...
#include <session.hpp>
Classes | |
struct | RetransmissionContext |
Provides context to your retrans handler. More... | |
Public Types | |
enum | SessionControl { shutdown, print, printnohb, debug, count } |
using | Control = ebitset_r< SessionControl > |
using | SequencePair = std::pair< const unsigned, const f8String > |
Public Member Functions | |
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... | |
Connection * | get_connection () |
Timer< Session > & | get_timer () |
const F8MetaCntx & | get_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 Tickval & | get_last_received () const |
const Tickval & | get_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 SessionID & | get_sid () const |
unsigned | get_next_send_seq () const |
void | set_login_parameters (const LoginParameters &loginParamaters) |
void | get_login_parameters (LoginParameters &loginParamaters) const |
const LoginParameters & | get_login_parameters () const |
void | set_reset_sequence_numbers_flag (bool flag) |
void | set_persister (Persister *pst) |
Control & | control () |
bool | is_shutdown () |
void | set_session_config (struct SessionConfig *sf) |
virtual F8API Message * | generate_logout (const char *msgstr=nullptr) |
virtual F8API Message * | generate_heartbeat (const f8String &testReqID) |
virtual F8API Message * | generate_resend_request (const unsigned begin, const unsigned end=0) |
virtual F8API Message * | generate_sequence_reset (const unsigned newseqnum, const bool gapfillflag=false) |
virtual F8API Message * | generate_test_request (const f8String &testReqID) |
virtual F8API Message * | generate_reject (const unsigned seqnum, const char *what, const char *msgtype=nullptr) |
virtual F8API Message * | generate_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 |
Static Public Member Functions | |
static const Message * | detach (const Message *&msg) |
static const f8String & | get_session_state_string (const States::SessionStates state) |
static F8API const f8String | copyright_string () |
Protected Member Functions | |
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 Message * | generate_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 bool | handle_application (const unsigned seqnum, const Message *&msg)=0 |
virtual void | state_change (const States::SessionStates before, const States::SessionStates after) |
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... | |
Message * | create_msg (const f8String &msg_type) const |
void | set_scheduler (int priority) |
void | set_affinity (int core_id) |
Protected Attributes | |
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 | |
static F8API const std::vector< f8String > | _state_names |
string representation of Sessionstates More... | |
Private Member Functions | |
void | atomic_init (States::SessionStates st) |
Fix8 Base Session. User sessions are derived from this class.
Definition at line 394 of file session.hpp.
Definition at line 403 of file session.hpp.
using FIX8::Session::SequencePair = std::pair<const unsigned, const f8String> |
Definition at line 615 of file session.hpp.
Enumerator | |
---|---|
shutdown | |
printnohb | |
debug | |
count |
Definition at line 401 of file session.hpp.
Session::Session | ( | const F8MetaCntx & | ctx, |
const SessionID & | sid, | ||
Persister * | persist = nullptr , |
||
Logger * | logger = nullptr , |
||
Logger * | plogger = nullptr |
||
) |
Ctor. Initiator.
ctx | reference to generated metadata |
sid | sessionid of connecting session |
persist | persister for this session |
logger | logger for this session |
plogger | protocol logger for this session |
Definition at line 105 of file session.cpp.
References _batchmsgs_buffer, _logger, _persist, _plogger, _sid, _timer, FIX8_MAX_MSG_LENGTH, glout_warn, and FIX8::HEADER_CALC_OFFSET().
Session::Session | ( | const F8MetaCntx & | ctx, |
const sender_comp_id & | sci = sender_comp_id() , |
||
Persister * | persist = nullptr , |
||
Logger * | logger = nullptr , |
||
Logger * | plogger = nullptr |
||
) |
Ctor. Acceptor.
ctx | reference to generated metadata |
sci | sender comp id of hosting session |
persist | persister for this session |
logger | logger for this session |
plogger | protocol logger for this session |
Definition at line 132 of file session.cpp.
References _batchmsgs_buffer, _timer, FIX8_MAX_MSG_LENGTH, and FIX8::HEADER_CALC_OFFSET().
|
virtual |
Dtor.
Definition at line 152 of file session.cpp.
References _connection, _logger, _per_spl, _persist, _plogger, _schedule, FIX8::Connection::cn_acceptor, FIX8::Connection::get_role(), FIX8::hypersleep< h_seconds >(), slout_info, and FIX8::Logger::stop().
|
inlinevirtual |
Check that the session is active for this application message
seqnum | message sequence number |
msg | Message |
Definition at line 736 of file session.hpp.
References _active.
Referenced by process().
|
protected |
Session start/stop service thread method.
Definition at line 788 of file session.cpp.
References _active, _connection, FIX8::Session_Schedule::_sch, _schedule, FIX8::Connection::is_connected(), is_shutdown(), slout_info, and FIX8::Schedule::test().
|
private |
Initialise atomic members.
st | the initial session state |
Definition at line 144 of file session.cpp.
References _active, _next_receive_seq, _next_send_seq, and do_state_change().
Referenced by start().
|
inlineprotectedvirtual |
Call user defined authentication with logon message.
Definition at line 520 of file session.hpp.
Referenced by handle_logon().
|
inline |
Clear reference to connection. Called by ~Connection() to clear reference.
connection | being deleted |
Definition at line 586 of file session.hpp.
Referenced by FIX8::Connection::~Connection().
void Session::compid_check | ( | const unsigned | seqnum, |
const Message * | msg, | ||
const SessionID & | id | ||
) | const |
Check that a message has the correct sender/target compid for this session. Throws BadCompidId on error.
Definition at line 415 of file session.cpp.
References FIX8::LoginParameters::_enforce_compids, _loginParameters, FIX8::MessageBase::get(), and FIX8::Message::Header().
Referenced by enforce().
|
inline |
Get the control object for this session.
Definition at line 774 of file session.hpp.
References _control.
|
static |
Return the version and copyright for this version
Definition at line 1207 of file session.cpp.
Referenced by start().
Create a new Fix message from metadata layer.
msg_type | message type string |
Definition at line 528 of file session.hpp.
References FIX8::F8MetaCntx::_bme, FIX8::BaseMsgEntry::_create, FIX8::Minst::_do, and FIX8::GeneratedTable< Key, Val >::find_ptr().
Referenced by generate_business_reject(), generate_heartbeat(), generate_logon(), generate_logout(), generate_reject(), generate_resend_request(), generate_sequence_reset(), and generate_test_request().
Detach message passed to handle_application. Will set source to 0; Not thread safe and should never be called across threads. It should only be called from Session::handle_application().
msg | ref to ptr containing message |
Definition at line 843 of file session.hpp.
|
inline |
Call the virtual state_change method with before and after, then set the new state
new_state | new session state to set |
Definition at line 827 of file session.hpp.
References state_change().
Referenced by atomic_init(), handle_heartbeat(), handle_logon(), handle_resend_request(), handle_sequence_reset(), heartbeat_service(), process(), retrans_callback(), sequence_check(), and start().
bool Session::enforce | ( | const unsigned | seqnum, |
const Message * | msg | ||
) |
Enforce session semantics. Checks compids, sequence numbers.
seqnum | message sequence number |
msg | Message |
Definition at line 252 of file session.cpp.
References _sid, _state, FIX8::Common_MsgType_SEQUENCE_RESET(), compid_check(), FIX8::MessageBase::get_msgtype(), FIX8::States::is_established(), sequence_check(), and FIX8::States::st_logon_received.
Referenced by handle_heartbeat(), handle_logon(), handle_logout(), handle_resend_request(), handle_sequence_reset(), and handle_test_request().
|
inline |
Log a message to the session logger. Do not check for level permission
what | string to log |
lev | log level |
fl | pointer to fileline |
value | optional value for the logger to use |
Definition at line 686 of file session.hpp.
References FIX8::Logger::enqueue().
|
virtual |
Generate a business_reject message.
seqnum | message sequence number |
msg | source message |
reason | rejection reason code |
what | rejection text |
Definition at line 901 of file session.cpp.
References FIX8::Common_MsgType_BUSINESS_REJECT(), create_msg(), and FIX8::MessageBase::get_msgtype().
Generate a heartbeat message.
testReqID | test request id |
Definition at line 878 of file session.cpp.
References FIX8::Common_MsgType_HEARTBEAT(), and create_msg().
Referenced by handle_test_request(), and heartbeat_service().
|
protectedvirtual |
Generate a logon message.
heartbeat_interval | heartbeat interval |
davi | default appl version id (FIXT) |
Definition at line 933 of file session.cpp.
References _loginParameters, FIX8::LoginParameters::_reset_sequence_numbers, FIX8::Common_MsgType_LOGON(), create_msg(), and FIX8::MessageBase::is_legal().
Referenced by handle_logon(), and start().
|
virtual |
Generate a logout message.
Definition at line 947 of file session.cpp.
References FIX8::Common_MsgType_LOGOUT(), and create_msg().
Referenced by heartbeat_service(), and process().
|
virtual |
Generate a reject message.
seqnum | message sequence number |
what | rejection text |
msgtype | offending msgtype |
Definition at line 888 of file session.cpp.
References FIX8::Common_MsgType_REJECT(), and create_msg().
Referenced by handle_logon(), and handle_outbound_reject().
|
virtual |
Generate a resend request message.
begin | begin sequence number |
end | sequence number |
Definition at line 957 of file session.cpp.
References FIX8::Common_MsgType_RESEND_REQUEST(), and create_msg().
Referenced by sequence_check().
|
virtual |
Generate a sequence reset message.
newseqnum | new sequence number |
gapfillflag | gap fill flag |
Definition at line 966 of file session.cpp.
References FIX8::Common_MsgType_SEQUENCE_RESET(), and create_msg().
Referenced by handle_resend_request(), and retrans_callback().
Generate a test request message.
testReqID | test request id |
Definition at line 924 of file session.cpp.
References FIX8::Common_MsgType_TEST_REQUEST(), and create_msg().
Referenced by heartbeat_service().
|
inline |
Get the connection object.
Definition at line 665 of file session.hpp.
References _connection.
Referenced by MyMenu::send_all_preloaded().
|
inline |
Get the metadata context object.
Definition at line 673 of file session.hpp.
References _ctx.
|
inline |
Return the last received timstamp
Definition at line 708 of file session.hpp.
References _last_received.
|
inline |
Return the last sent timstamp
Definition at line 712 of file session.hpp.
References _last_sent.
|
inline |
Get the LoginParameters
loginParamaters | to populate |
Definition at line 758 of file session.hpp.
References _loginParameters.
|
inline |
Get the LoginParameters
Definition at line 762 of file session.hpp.
References _loginParameters.
|
inline |
Get the next sender sequence number
Definition at line 750 of file session.hpp.
References _next_send_seq.
Referenced by FIX8::MemoryPersister::get(), and FIX8::FilePersister::get().
|
inline |
Get the current session state enumeration
Definition at line 836 of file session.hpp.
References _state.
|
inlinestatic |
Find the string representation for the given session state
state | session state |
Definition at line 853 of file session.hpp.
|
inline |
Get the session id for this session.
Definition at line 746 of file session.hpp.
References _sid.
Get the timer object.
Definition at line 669 of file session.hpp.
References _timer.
|
inlineprotectedvirtual |
Administrative message callback. Called on receipt of all admin messages.
seqnum | message sequence number |
msg | Message |
Definition at line 490 of file session.hpp.
Referenced by process().
|
protectedpure virtual |
Application message callback. Called on receipt of all non-admin messages. You must implement this method. The message is passed as a reference to a pointer. Your application can detach and take ownership. If you want to take ownership, take a copy of the pointer and then set msg to 0. See Session::detach()
seqnum | message sequence number |
msg | reference to Message ptr |
Implemented in hf_session_server, myfix_session_server, hf_session_client, and myfix_session_client.
Referenced by process().
|
protectedvirtual |
Heartbeat callback.
seqnum | message sequence number |
msg | Message |
Definition at line 868 of file session.cpp.
References _state, do_state_change(), enforce(), FIX8::States::st_continuous, and FIX8::States::st_test_request_sent.
Referenced by process().
|
protectedvirtual |
Logon callback.
seqnum | message sequence number |
msg | Message |
Definition at line 470 of file session.cpp.
References FIX8::F8MetaCntx::_beginStr, FIX8::LoginParameters::_clients, _connection, _ctx, FIX8::LoginParameters::_enforce_compids, _hb_processor, _logger, FIX8::LoginParameters::_login_schedule, _loginParameters, _next_receive_seq, _next_send_seq, _per_spl, _persist, _plogger, _req_next_receive_seq, _req_next_send_seq, _schedule, _sci, FIX8::SessionConfig::_ses, _sf, _sid, _state, _timer, authenticate(), FIX8::Connection::cn_initiator, FIX8::Common_ResetSeqNumFlag(), FIX8::Configuration::create_logger(), FIX8::Configuration::create_persister(), do_state_change(), enforce(), generate_logon(), generate_reject(), FIX8::MessageBase::get(), FIX8::Connection::get_hb_interval(), FIX8::MessageBase::get_msgtype(), FIX8::Connection::get_peer_socket_address(), FIX8::Connection::get_pmodel(), FIX8::Connection::get_role(), FIX8::SessionID::get_senderCompID(), glout_error, glout_info, glout_warn, FIX8::MessageBase::have(), FIX8::Message::Header(), FIX8::Schedule::is_valid(), FIX8::pm_coro, FIX8::Configuration::protocol_log, recover_seqnums(), send(), FIX8::Configuration::session_log, FIX8::Connection::set_hb_interval(), slout_error, slout_info, FIX8::States::st_continuous, FIX8::States::st_logon_received, FIX8::States::st_session_terminated, stop(), and FIX8::Schedule::test().
Referenced by process().
|
protectedvirtual |
Logout callback.
seqnum | message sequence number |
msg | Message |
Definition at line 630 of file session.cpp.
References enforce(), and slout_info.
Referenced by process().
|
protectedvirtual |
Outbound Reject callback. Override to receive callback when an inbound message has caused a reject
seqnum | message sequence number |
msg | Message |
errstr | reject message text |
Definition at line 782 of file session.cpp.
References generate_reject(), FIX8::MessageBase::get_msgtype(), and send().
Referenced by handle_resend_request(), and process().
|
inlineprotectedvirtual |
Reject callback.
seqnum | message sequence number |
msg | Message |
Definition at line 484 of file session.hpp.
Referenced by process().
|
protectedvirtual |
Resend request callback.
seqnum | message sequence number |
msg | Message |
Definition at line 663 of file session.cpp.
References _next_send_seq, _persist, _state, do_state_change(), enforce(), generate_sequence_reset(), FIX8::Persister::get(), FIX8::MessageBase::get(), handle_outbound_reject(), retrans_callback(), send(), slout_debug, slout_warn, and FIX8::States::st_resend_request_received.
Referenced by process().
|
protectedvirtual |
Sequence reset callback.
seqnum | message sequence number |
msg | Message |
Definition at line 642 of file session.cpp.
References _next_receive_seq, _state, do_state_change(), enforce(), FIX8::MessageBase::get(), slout_debug, FIX8::States::st_continuous, and FIX8::States::st_resend_request_sent.
Referenced by process().
|
protectedvirtual |
Test request callback.
seqnum | message sequence number |
msg | Message |
Definition at line 771 of file session.cpp.
References enforce(), generate_heartbeat(), FIX8::MessageBase::get(), and send().
Referenced by process().
|
protected |
Heartbeat generation service thread method.
Definition at line 808 of file session.cpp.
References _connection, _last_received, _last_sent, _loginParameters, FIX8::LoginParameters::_silent_disconnect, _state, do_state_change(), FIX8::Logger::Error, generate_heartbeat(), generate_logout(), generate_test_request(), FIX8::Connection::get_hb_interval(), FIX8::Connection::get_hb_interval20pc(), FIX8::Connection::is_connected(), is_shutdown(), log(), FIX8::Tickval::now(), FIX8::Tickval::secs(), send(), slout_error, FIX8::States::st_logoff_sent, FIX8::States::st_session_terminated, FIX8::States::st_test_request_sent, stop(), and FIX8::Logger::Warn.
|
inline |
Check if the given log level is set for the session logger
level | level to test |
Definition at line 678 of file session.hpp.
References FIX8::Logger::is_loggable().
|
inline |
See if this session is being shutdown.
Definition at line 778 of file session.hpp.
References FIX8::ebitset_r< T, B >::has(), shutdown, and FIX8::States::st_session_terminated.
Referenced by activation_service(), client_process(), and heartbeat_service().
|
inline |
Log a message to the session logger.
what | string to log |
lev | log level |
fl | pointer to fileline |
value | optional value for the logger to use |
Definition at line 695 of file session.hpp.
References FIX8::Logger::send().
Referenced by heartbeat_service().
|
virtual |
Modify the header if desired. Called when message is sent.
msg | Message |
Definition at line 1003 of file session.cpp.
Referenced by send_process().
|
inlineprotectedvirtual |
Permit modification of message just prior to sending.
msg | Message |
Definition at line 514 of file session.hpp.
Referenced by send_process().
|
inline |
Log a message to the protocol logger.
what | Fix message (string) to log |
lev | log level |
direction | 0=out, 1=in |
Definition at line 703 of file session.hpp.
References FIX8::Logger::send().
Referenced by process(), and send_process().
|
virtual |
Process inbound messages. Called by connection object.
from | raw fix message |
Definition at line 277 of file session.cpp.
References _control, _ctx, _loginParameters, _next_receive_seq, FIX8::LoginParameters::_no_chksum_flag, FIX8::LoginParameters::_permissive_mode_flag, _plogger, FIX8::LoginParameters::_reliable, FIX8::LoginParameters::_silent_disconnect, _state, activation_check(), FIX8::Common_MsgByte_HEARTBEAT(), FIX8::Common_MsgByte_LOGON(), FIX8::Common_MsgByte_LOGOUT(), FIX8::Common_MsgByte_REJECT(), FIX8::Common_MsgByte_RESEND_REQUEST(), FIX8::Common_MsgByte_SEQUENCE_RESET(), FIX8::Common_MsgByte_TEST_REQUEST(), FIX8::Common_MsgType_HEARTBEAT(), FIX8::default_field_separator(), do_state_change(), FIX8::Message::factory(), FILE_LINE, FIX8::f8Exception::force_logoff(), generate_logout(), FIX8::MessageBase::get_msgtype(), glout_fatal, handle_admin(), handle_application(), handle_heartbeat(), handle_logon(), handle_logout(), handle_outbound_reject(), handle_reject(), handle_resend_request(), handle_sequence_reset(), handle_test_request(), FIX8::Logger::has_flag(), FIX8::Logger::inbound, FIX8::Logger::Info, FIX8::Message::is_admin(), plog(), print, printnohb, send(), slout_debug, slout_error, slout_fatal, FIX8::States::st_logoff_sent, FIX8::States::st_logon_received, FIX8::States::st_session_terminated, FIX8::States::st_wait_for_logon, stop(), update_persist_seqnums(), and FIX8::f8Exception::what().
|
protectedvirtual |
Recover next expected and next to send sequence numbers from persitence layer.
Definition at line 1124 of file session.cpp.
References _connection, _next_receive_seq, _next_send_seq, _per_spl, _persist, FIX8::Persister::get(), FIX8::Connection::get_pmodel(), FIX8::pm_coro, and slout_info.
Referenced by handle_logon(), and start().
|
virtual |
Retransmission callback. Called by framework with each message to be resent.
with | pair of sequence number and raw fix message |
rctx | retransmission context |
Definition at line 707 of file session.cpp.
References FIX8::Session::RetransmissionContext::_begin, _ctx, FIX8::Session::RetransmissionContext::_interrupted_seqnum, FIX8::Session::RetransmissionContext::_last, _next_send_seq, FIX8::Session::RetransmissionContext::_no_more_records, do_state_change(), FIX8::Message::factory(), generate_sequence_reset(), send(), slout_debug, and FIX8::States::st_continuous.
Referenced by handle_resend_request().
|
virtual |
Send message.
msg | Message |
destroy | if true, destroy message after send |
custom_seqnum | override sequence number with this value |
no_increment | if true, don't increment the seqnum after sending |
Definition at line 978 of file session.cpp.
References _connection, FIX8::Message::set_custom_seqnum(), FIX8::Message::set_no_increment(), and FIX8::Connection::write().
Referenced by handle_logon(), handle_outbound_reject(), handle_resend_request(), handle_test_request(), heartbeat_service(), process(), retrans_callback(), sequence_check(), and start().
|
virtual |
Send message - non-pipelined version. WARNING: be sure you don't inadvertently use this method. Symptoms will be out of sequence messages (seqnum==1) and core dumping.
msg | Message |
custom_seqnum | override sequence number with this value |
no_increment | if true, don't increment the seqnum after sending |
Definition at line 987 of file session.cpp.
References _connection, FIX8::Message::set_custom_seqnum(), FIX8::Message::set_no_increment(), and FIX8::Connection::write().
|
virtual |
Send a batch of messages. During this call HB and test requests are suspended.
msgs | vector of Message ptrs |
destroy | if true, destroy message after send |
Definition at line 997 of file session.cpp.
References _connection, and FIX8::Connection::write_batch().
bool Session::send_process | ( | Message * | msg | ) |
Process message (encode) and send.
msg | Message |
Definition at line 1009 of file session.cpp.
References FIX8::LoginParameters::_always_seqnum_assign, _batchmsgs_buffer, _connection, _last_sent, _loginParameters, _next_receive_seq, _next_send_seq, _per_spl, _persist, _plogger, _sid, FIX8::Common_MsgSeqNum(), FIX8::Common_MsgType_SEQUENCE_RESET(), FIX8::Common_PossDupFlag(), FIX8::Common_SenderCompID(), FIX8::Common_TargetCompID(), FIX8_MAX_MSG_LENGTH, FIX8::MessageBase::get(), FIX8::Message::get_custom_seqnum(), FIX8::Connection::get_pmodel(), FIX8::SessionID::get_senderCompID(), FIX8::SessionID::get_targetCompID(), FIX8::Logger::has_flag(), FIX8::MessageBase::have(), FIX8::Message::Header(), FIX8::HEADER_CALC_OFFSET(), FIX8::Logger::Info, modify_header(), modify_outbound(), FIX8::Tickval::now(), FIX8::Logger::outbound, plog(), FIX8::pm_coro, FIX8::Persister::put(), FIX8::MessageBase::remove(), FIX8::Connection::send(), slout_debug, slout_error, and FIX8::f8Exception::what().
Referenced by FIX8::FIXWriter::write(), and FIX8::FIXWriter::write_batch().
bool Session::sequence_check | ( | const unsigned | seqnum, |
const Message * | msg | ||
) |
Check that a message is in the correct sequence for this session. Will generated resend request if required. Throws InvalidMsgSequence, MissingMandatoryField, BadSendingTime.
seqnum | message sequence number |
msg | Message |
Definition at line 427 of file session.cpp.
References _next_receive_seq, FIX8::SessionConfig::_ses, _sf, _state, do_state_change(), generate_resend_request(), FIX8::MessageBase::get(), FIX8::Configuration::get_ignore_logon_sequence_check_flag(), FIX8::Message::Header(), FIX8::BaseField::print(), send(), slout_warn, FIX8::States::st_continuous, and FIX8::States::st_resend_request_sent.
Referenced by enforce().
|
protected |
Set the CPU affinity mask for the given thread
core_id | core to mask on |
Definition at line 1200 of file session.cpp.
References slout_error.
|
inline |
Set the LoginParameters
loginParamaters | to populate from |
Definition at line 754 of file session.hpp.
|
inline |
Set the persister.
pst | pointer to persister object |
Definition at line 770 of file session.hpp.
|
inline |
Set the reset_sequence_numbers flag, defaults to value set in config file (default false)
flag | true or false |
Definition at line 766 of file session.hpp.
References FIX8::LoginParameters::_reset_sequence_numbers.
|
protected |
Set the scheduling policy for the current thread
priority | scheduler priority |
Definition at line 1194 of file session.cpp.
References slout_error.
|
inline |
Definition at line 782 of file session.hpp.
int Session::start | ( | Connection * | connection, |
bool | wait = true , |
||
const unsigned | send_seqnum = 0 , |
||
const unsigned | recv_seqnum = 0 , |
||
const f8String | davi = f8String() |
||
) |
Start the session.
connection | established connection |
wait | if true, thread will wait till session ends before returning |
send_seqnum | if supplied, override the send login sequence number, set next send to seqnum+1 |
recv_seqnum | if supplied, override the receive login sequence number, set next recv to seqnum+1 |
davi | default appl version id (FIXT) |
Definition at line 167 of file session.cpp.
References _connection, _control, _logger, _loginParameters, _next_receive_seq, _next_send_seq, _plogger, _req_next_receive_seq, _req_next_send_seq, FIX8::LoginParameters::_reset_sequence_numbers, _schedule, FIX8::SessionConfig::_ses, _session_scheduler, _sf, _timer, atomic_init(), FIX8::ebitset_r< T, B >::clear(), FIX8::Connection::cn_acceptor, FIX8::Connection::cn_initiator, FIX8::Connection::connect(), copyright_string(), FIX8::Configuration::create_session_schedule(), do_state_change(), generate_logon(), FIX8::Connection::get_hb_interval(), FIX8::Connection::get_role(), glout_info, FIX8::Connection::join(), FIX8::Logger::purge_thread_codes(), recover_seqnums(), send(), shutdown, slout_info, FIX8::States::st_logon_sent, FIX8::States::st_not_logged_in, FIX8::States::st_wait_for_logon, and FIX8::Connection::start().
|
inlineprotectedvirtual |
This method id called whenever a session state change occurs
before | previous session state |
after | new session state |
Reimplemented in myfix_session_server, and myfix_session_client.
Definition at line 510 of file session.hpp.
Referenced by do_state_change().
void Session::stop | ( | ) |
stop the session.
Definition at line 230 of file session.cpp.
References _connection, _control, _per_spl, _persist, _timer, FIX8::Connection::cn_initiator, FIX8::Connection::get_pmodel(), FIX8::Connection::get_role(), FIX8::hypersleep< h_milliseconds >(), FIX8::pm_coro, shutdown, FIX8::Persister::stop(), and FIX8::Connection::stop().
Referenced by client_process(), handle_logon(), heartbeat_service(), and process().
void Session::update_persist_seqnums | ( | ) |
Force persister to sync next send/receive seqnums.
Definition at line 266 of file session.cpp.
References _connection, _next_receive_seq, _next_send_seq, _per_spl, _persist, FIX8::Connection::get_pmodel(), FIX8::pm_coro, and FIX8::Persister::put().
Referenced by process().
|
inline |
Update the last received time.
Definition at line 718 of file session.hpp.
References FIX8::Tickval::now().
|
inline |
Update the last sent time.
Definition at line 715 of file session.hpp.
References FIX8::Tickval::now().
|
protected |
Definition at line 409 of file session.hpp.
Referenced by activation_check(), activation_service(), and atomic_init().
|
protected |
Definition at line 426 of file session.hpp.
Referenced by send_process(), and Session().
|
protected |
Definition at line 413 of file session.hpp.
Referenced by activation_service(), get_connection(), handle_logon(), heartbeat_service(), recover_seqnums(), send(), send_batch(), send_process(), start(), stop(), update_persist_seqnums(), and ~Session().
|
protected |
|
protected |
Definition at line 411 of file session.hpp.
Referenced by get_ctx(), handle_logon(), process(), and retrans_callback().
|
protected |
Definition at line 425 of file session.hpp.
Referenced by handle_logon().
|
protected |
Definition at line 410 of file session.hpp.
Referenced by get_last_received(), and heartbeat_service().
|
protected |
Definition at line 410 of file session.hpp.
Referenced by get_last_sent(), heartbeat_service(), and send_process().
|
protected |
Definition at line 422 of file session.hpp.
Referenced by handle_logon(), Session(), start(), and ~Session().
|
protected |
Definition at line 418 of file session.hpp.
Referenced by compid_check(), generate_logon(), get_login_parameters(), handle_logon(), heartbeat_service(), process(), send_process(), and start().
|
protected |
Definition at line 407 of file session.hpp.
Referenced by atomic_init(), handle_logon(), handle_sequence_reset(), process(), recover_seqnums(), send_process(), sequence_check(), start(), and update_persist_seqnums().
|
protected |
Definition at line 407 of file session.hpp.
Referenced by atomic_init(), get_next_send_seq(), handle_logon(), handle_resend_request(), recover_seqnums(), retrans_callback(), send_process(), start(), and update_persist_seqnums().
|
protected |
Definition at line 420 of file session.hpp.
Referenced by handle_logon(), recover_seqnums(), send_process(), stop(), update_persist_seqnums(), and ~Session().
|
protected |
Definition at line 421 of file session.hpp.
Referenced by handle_logon(), handle_resend_request(), recover_seqnums(), send_process(), Session(), stop(), update_persist_seqnums(), and ~Session().
|
protected |
Definition at line 422 of file session.hpp.
Referenced by handle_logon(), process(), send_process(), Session(), start(), and ~Session().
|
protected |
Definition at line 414 of file session.hpp.
Referenced by handle_logon(), and start().
|
protected |
Definition at line 414 of file session.hpp.
Referenced by handle_logon(), and start().
|
protected |
Definition at line 427 of file session.hpp.
Referenced by activation_service(), handle_logon(), start(), and ~Session().
|
protected |
Definition at line 412 of file session.hpp.
Referenced by handle_logon().
|
protected |
Definition at line 425 of file session.hpp.
Referenced by start().
|
protected |
Definition at line 416 of file session.hpp.
Referenced by handle_logon(), sequence_check(), and start().
|
protected |
Definition at line 415 of file session.hpp.
Referenced by enforce(), get_sid(), handle_logon(), send_process(), and Session().
|
protected |
Definition at line 408 of file session.hpp.
Referenced by enforce(), get_session_state(), handle_heartbeat(), handle_logon(), handle_resend_request(), handle_sequence_reset(), heartbeat_service(), process(), and sequence_check().
|
staticprotected |
string representation of Sessionstates
Definition at line 430 of file session.hpp.
Definition at line 424 of file session.hpp.
Referenced by get_timer(), handle_logon(), Session(), start(), and stop().