Ejemplo n.º 1
0
	/// Ctor. Prepares session for connection as an initiator.
	ClientSession (const F8MetaCntx& ctx, const std::string& conf_file,
		const std::string& session_name, bool init_con_later=false) :
		ClientSessionBase(ctx, conf_file, session_name),
		_sci(get_sender_comp_id(_ses)), _tci(get_target_comp_id(_ses)),
		_id(_ctx._beginStr, _sci, _tci),
		_log(create_logger(_ses, session_log, &_id)),
		_plog(create_logger(_ses, protocol_log, &_id)),
		_persist(create_persister(_ses, nullptr, this->_loginParameters._reset_sequence_numbers)),
		_session(new T(_ctx, _id, _persist, _log, _plog)),
		_addr(get_address(_ses))
#ifdef FIX8_HAVE_OPENSSL
		,_ssl(get_ssl_context(_ses), true)
#endif
	{
		if (!init_con_later)
		{
#ifdef FIX8_HAVE_OPENSSL
			bool secured(_ssl.is_secure());
			_sock = secured
				? new Poco::Net::SecureStreamSocket(_ssl._context)
				: new Poco::Net::StreamSocket;
#else
			bool secured(false);
			_sock = new Poco::Net::StreamSocket;
#endif
			_cc = new ClientConnection(_sock, _addr, *_session, this->_loginParameters._hb_int, get_process_model(_ses), true, secured);
		}

		_session->set_login_parameters(this->_loginParameters);
		_session->set_session_config(this);
	}
Ejemplo n.º 2
0
//-------------------------------------------------------------------------------------------------
string& Configuration::get_logname(const XmlElement *from, string& to, const SessionID *sid) const
{
	if (sid)
		to += ('.' + sid->get_senderCompID()() + '.' + sid->get_targetCompID()());
	else if (from && from->FindAttr("use_session_id", false))
		to += ('.' + get_sender_comp_id(from)() + '.' + get_target_comp_id(from)());

	return to;
}
Ejemplo n.º 3
0
//-------------------------------------------------------------------------------------------------
Persister *Configuration::create_persister(const XmlElement *from, const SessionID *sid, bool flag) const
{
	string name, type;
	const XmlElement *which;
	if (from && from->GetAttr("persist", name) && (which = find_persister(name)) && which->GetAttr("type", type))
	{
		if (type == "mem")
			return new MemoryPersister;

		string dir("./"), db("persist_db");
		which->GetAttr("dir", dir);
		which->GetAttr("db", db);

		if (sid)
			db += ('.' + sid->get_senderCompID()() + '.' + sid->get_targetCompID()());
		else if (which->FindAttr("use_session_id", false))
			db += ('.' + get_sender_comp_id(from)() + '.' + get_target_comp_id(from)());

#if defined HAVE_BDB
		if (type == "bdb")
		{
			scoped_ptr<BDBPersister> result(new BDBPersister);
			if (result->initialise(dir, db, flag))
				return result.release();
		}
		else
#endif
		if (type == "file")
		{
			scoped_ptr<FilePersister> result(new FilePersister(which->FindAttr("rotation", 0)));
			if (result->initialise(dir, db, flag))
				return result.release();
		}
	}

	return 0;
}