Exemple #1
0
        public Session(
            IApplication app, IMessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
            SessionSchedule sessionSchedule, int heartBtInt, ILogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID)
        {
            this.Application = app;
            this.SessionID = sessID;
            this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
            this.schedule_ = sessionSchedule;
            this.msgFactory_ = msgFactory;

            this.SenderDefaultApplVerID = senderDefaultApplVerID;

            this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
            if (this.SessionID.IsFIXT)
                this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
            else
                this.ApplicationDataDictionary = this.SessionDataDictionary;

            ILog log;
            if (null != logFactory)
                log = logFactory.Create(sessID);
            else
                log = new NullLog();

            state_ = new SessionState(log, heartBtInt)
            {
                MessageStore = storeFactory.Create(sessID)
            };

            // Configuration defaults.
            // Will be overridden by the SessionFactory with values in the user's configuration.
            this.PersistMessages = true;
            this.ResetOnDisconnect = false;
            this.SendRedundantResendRequests = false;
            this.ValidateLengthAndChecksum = true;
            this.CheckCompID = true;
            this.MillisecondsInTimeStamp = true;
            this.EnableLastMsgSeqNumProcessed = false;
            this.MaxMessagesInResendRequest = 0;
            this.SendLogoutBeforeTimeoutDisconnect = false;
            this.IgnorePossDupResendRequests = false;
            this.RequiresOrigSendingTime = true;
            this.CheckLatency = true;
            this.MaxLatency = 120;

            if (!IsSessionTime)
                Reset("Out of SessionTime (Session construction)");
            else if (IsNewSession)
                Reset("New session");

            lock (sessions_)
            {
                sessions_[this.SessionID] = this;
            }

            this.Application.OnCreate(this.SessionID);
            this.Log.OnEvent("Created session");
        }
Exemple #2
0
        /// FIXME
        public Session(
            Application app, MessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
            SessionSchedule sessionSchedule, int heartBtInt, LogFactory logFactory, IMessageFactory msgFactory)
        {
            this.Application            = app;
            this.SessionID              = sessID;
            this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
            this.schedule_              = sessionSchedule;
            this.msgFactory_            = msgFactory;

            this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
            if (this.SessionID.IsFIXT)
            {
                this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
            }
            else
            {
                this.ApplicationDataDictionary = this.SessionDataDictionary;
            }

            Log log;

            if (null != logFactory)
            {
                log = logFactory.Create(sessID);
            }
            else
            {
                log = new NullLog();
            }

            state_ = new SessionState(log, heartBtInt);
            state_.MessageStore = storeFactory.Create(sessID);

            this.PersistMessages             = true;
            this.ResetOnDisconnect           = false;
            this.SendRedundantResendRequests = false;
            this.ValidateLengthAndChecksum   = true;
            this.CheckCompID = true;

            if (!CheckSessionTime())
            {
                Reset();
            }

            lock (sessions_)
            {
                sessions_[this.SessionID] = this;
            }

            this.Application.OnCreate(this.SessionID);
            this.Log.OnEvent("Created session");
        }
Exemple #3
0
 public SessionThatTracksOutbound(
     QuickFix.IApplication app,
     QuickFix.IMessageStoreFactory storeFactory,
     QuickFix.SessionID sessID,
     QuickFix.DataDictionaryProvider dataDictProvider,
     QuickFix.SessionSchedule sessionSchedule,
     int heartBtInt,
     QuickFix.ILogFactory logFactory,
     QuickFix.IMessageFactory msgFactory,
     string senderDefaultApplVerID)
     : base(app, storeFactory, sessID, dataDictProvider, sessionSchedule, heartBtInt, logFactory, msgFactory, senderDefaultApplVerID)
 {
 }
Exemple #4
0
        /// FIXME
        public Session(
            Application app, MessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
            SessionSchedule sessionSchedule, int heartBtInt, LogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID)
        {
            this.Application = app;
            this.SessionID = sessID;
            this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
            this.schedule_ = sessionSchedule;
            this.msgFactory_ = msgFactory;

            this.SenderDefaultApplVerID = senderDefaultApplVerID;

            this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
            if (this.SessionID.IsFIXT)
                this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
            else
                this.ApplicationDataDictionary = this.SessionDataDictionary;

            Log log;
            if (null != logFactory)
                log = logFactory.Create(sessID);
            else
                log = new NullLog();

            state_ = new SessionState(log, heartBtInt)
            {
                MessageStore = storeFactory.Create(sessID)
            };

            this.PersistMessages = true;
            this.ResetOnDisconnect = false;
            this.SendRedundantResendRequests = false;
            this.ValidateLengthAndChecksum = true;
            this.CheckCompID = true;
            this.MillisecondsInTimeStamp = true;
            this.EnableLastMsgSeqNumProcessed = false;
            this.MaxMessagesInResendRequest = 0;
            this.SendLogoutBeforeTimeoutDisconnect = false;
            this.IgnorePossDupResendRequests = false;

            if (!IsSessionTime)
                Reset();

            lock (sessions_)
            {
                sessions_[this.SessionID] = this;
            }

            this.Application.OnCreate(this.SessionID);
            this.Log.OnEvent("Created session");
        }
Exemple #5
0
        /// FIXME
        public Session(
            Application app, MessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
            SessionSchedule sessionSchedule, int heartBtInt, LogFactory logFactory, IMessageFactory msgFactory)
        {
            this.Application = app;
            this.SessionID = sessID;
            this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
            this.schedule_ = sessionSchedule;
            this.msgFactory_ = msgFactory;

            this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
            if (this.SessionID.IsFIXT)
                this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
            else
                this.ApplicationDataDictionary = this.SessionDataDictionary;

            Log log;
            if (null != logFactory)
                log = logFactory.Create(sessID);
            else
                log = new NullLog();

            state_ = new SessionState(log, heartBtInt);
            state_.MessageStore = storeFactory.Create(sessID);

            this.PersistMessages = true;
            this.ResetOnDisconnect = false;
            this.SendRedundantResendRequests = false;
            this.ValidateLengthAndChecksum = true;
            this.CheckCompID = true;

            if (!CheckSessionTime())
                Reset();

            lock (sessions_)
            {
                sessions_[this.SessionID] = this;
            }

            this.Application.OnCreate(this.SessionID);
            this.Log.OnEvent("Created session");
        }
Exemple #6
0
        protected void ProcessFixTDataDictionaries(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider)
        {
            provider.AddTransportDataDictionary(sessionID.BeginString, createDataDictionary(sessionID, settings, SessionSettings.TRANSPORT_DATA_DICTIONARY, sessionID.BeginString));

            foreach (KeyValuePair <string, string> setting in settings)
            {
                if (setting.Key.StartsWith(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    if (setting.Key.Equals(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                    {
                        Fields.ApplVerID applVerId       = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, SessionSettings.APP_DATA_DICTIONARY, sessionID.BeginString);
                        provider.AddApplicationDataDictionary(applVerId.Obj, dd);
                    }
                    else
                    {
                        int offset = setting.Key.IndexOf(".");
                        if (offset == -1)
                        {
                            throw new System.ArgumentException(string.Format("Malformed {0} : {1}", SessionSettings.APP_DATA_DICTIONARY, setting.Key));
                        }

                        string beginStringQualifier      = setting.Key.Substring(offset);
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, setting.Key, beginStringQualifier);
                        provider.AddApplicationDataDictionary(Message.GetApplVerID(beginStringQualifier).Obj, dd);
                    }
                }
            }
        }
 /// TODO need to make deeper copy?
 public DataDictionaryProvider(DataDictionaryProvider src)
 {
     transportDataDictionaries_ = new Dictionary<string, DataDictionary.DataDictionary>(src.transportDataDictionaries_);
     applicationDataDictionaries_ = new Dictionary<string, DataDictionary.DataDictionary>(src.applicationDataDictionaries_);
     emptyDataDictionary_ = new DataDictionary.DataDictionary(src.emptyDataDictionary_);
 }
        public Session Create(SessionID sessionID, QuickFix.Dictionary settings)
        {
            string connectionType = settings.GetString(SessionSettings.CONNECTION_TYPE);
            if (!"acceptor".Equals(connectionType) && !"initiator".Equals(connectionType))
                throw new ConfigError("Invalid ConnectionType");

            if ("acceptor".Equals(connectionType) && settings.Has(SessionSettings.SESSION_QUALIFIER))
                throw new ConfigError("SessionQualifier cannot be used with acceptor.");

            bool useDataDictionary = true;
            if (settings.Has(SessionSettings.USE_DATA_DICTIONARY))
                useDataDictionary = settings.GetBool(SessionSettings.USE_DATA_DICTIONARY);

            QuickFix.Fields.ApplVerID defaultApplVerID = null;
            if (sessionID.IsFIXT)
            {
                if (!settings.Has(SessionSettings.DEFAULT_APPLVERID))
                {
                    throw new ConfigError("ApplVerID is required for FIXT transport");
                }
                defaultApplVerID = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));

            }

            DataDictionaryProvider dd = new DataDictionaryProvider();
            if (useDataDictionary)
            {
                if (sessionID.IsFIXT)
                    ProcessFixTDataDictionaries(sessionID, settings, dd);
                else
                    ProcessFixDataDictionary(sessionID, settings, dd);
            }

            int heartBtInt = 0;
            if ( connectionType == "initiator" )
            {
                heartBtInt = System.Convert.ToInt32(settings.GetLong( SessionSettings.HEARTBTINT ));
                if ( heartBtInt <= 0 )
                    throw new ConfigError( "Heartbeat must be greater than zero" );
            }
            string senderDefaultApplVerId = "";
            if(defaultApplVerID != null)
                senderDefaultApplVerId = defaultApplVerID.Obj;

            Session session = new Session(
                application_,
                messageStoreFactory_,
                sessionID,
                dd,
                new SessionSchedule(settings),
                heartBtInt,
                logFactory_,
                messageFactory_,
                senderDefaultApplVerId);

            if (settings.Has(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS))
                session.SendRedundantResendRequests = settings.GetBool(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS);
            if (settings.Has(SessionSettings.RESEND_SESSION_LEVEL_REJECTS))
                session.ResendSessionLevelRejects = settings.GetBool(SessionSettings.RESEND_SESSION_LEVEL_REJECTS);
            /** FIXME - implement optional settings
            if (settings.Has(SessionSettings.CHECK_COMPID))
                session.SetCheckCompId(settings.GetBool(SessionSettings.CHECK_COMPID));
             */
            if (settings.Has(SessionSettings.CHECK_LATENCY))
                session.CheckLatency = settings.GetBool(SessionSettings.CHECK_LATENCY);
            if (settings.Has(SessionSettings.MAX_LATENCY))
                session.MaxLatency = settings.GetInt(SessionSettings.MAX_LATENCY);
            if (settings.Has(SessionSettings.LOGON_TIMEOUT))
                session.LogonTimeout = settings.GetInt(SessionSettings.LOGON_TIMEOUT);
            if (settings.Has(SessionSettings.LOGOUT_TIMEOUT))
                session.LogoutTimeout = settings.GetInt(SessionSettings.LOGOUT_TIMEOUT);
            if (settings.Has(SessionSettings.RESET_ON_LOGON))
                session.ResetOnLogon = settings.GetBool(SessionSettings.RESET_ON_LOGON);
            if (settings.Has(SessionSettings.RESET_ON_LOGOUT))
                session.ResetOnLogout = settings.GetBool(SessionSettings.RESET_ON_LOGOUT);
            if (settings.Has(SessionSettings.RESET_ON_DISCONNECT))
                session.ResetOnDisconnect = settings.GetBool(SessionSettings.RESET_ON_DISCONNECT);
            if (settings.Has(SessionSettings.REFRESH_ON_LOGON))
                session.RefreshOnLogon = settings.GetBool(SessionSettings.REFRESH_ON_LOGON);
            if (settings.Has(SessionSettings.PERSIST_MESSAGES))
                session.PersistMessages = settings.GetBool(SessionSettings.PERSIST_MESSAGES);
            if (settings.Has(SessionSettings.MILLISECONDS_IN_TIMESTAMP))
                session.MillisecondsInTimeStamp = settings.GetBool(SessionSettings.MILLISECONDS_IN_TIMESTAMP);
            if (settings.Has(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED))
                session.EnableLastMsgSeqNumProcessed = settings.GetBool(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED);
            if (settings.Has(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST))
                session.MaxMessagesInResendRequest = settings.GetInt(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST);
            if (settings.Has(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT))
                session.SendLogoutBeforeTimeoutDisconnect = settings.GetBool(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT);
            if (settings.Has(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS))
                session.IgnorePossDupResendRequests = settings.GetBool(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS);
            if (settings.Has(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM))
                session.ValidateLengthAndChecksum = settings.GetBool(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM);
            if (settings.Has(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME))
                session.RequiresOrigSendingTime = settings.GetBool(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME);

            return session;
        }
        protected void ProcessFixTDataDictionaries(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider)
        {
            provider.AddTransportDataDictionary(sessionID.BeginString, createDataDictionary(sessionID, settings, SessionSettings.TRANSPORT_DATA_DICTIONARY, sessionID.BeginString));

            foreach (KeyValuePair<string, string> setting in settings)
            {
                if (setting.Key.StartsWith(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    if (setting.Key.Equals(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                    {
                        Fields.ApplVerID applVerId = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, SessionSettings.APP_DATA_DICTIONARY, sessionID.BeginString);
                        provider.AddApplicationDataDictionary(applVerId.Obj, dd);
                    }
                    else
                    {
                        int offset = setting.Key.IndexOf(".");
                        if (offset == -1)
                            throw new System.ArgumentException(string.Format("Malformed {0} : {1}", SessionSettings.APP_DATA_DICTIONARY, setting.Key));

                        string beginStringQualifier = setting.Key.Substring(offset);
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, setting.Key, beginStringQualifier);
                        provider.AddApplicationDataDictionary(Message.GetApplVerID(beginStringQualifier).Obj, dd);
                    }
                }
            }
        }
 protected void ProcessFixDataDictionary(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider)
 {
     DataDictionary.DataDictionary dataDictionary = createDataDictionary(sessionID, settings, SessionSettings.DATA_DICTIONARY, sessionID.BeginString);
     provider.AddTransportDataDictionary(sessionID.BeginString, dataDictionary);
     provider.AddApplicationDataDictionary(FixValues.ApplVerID.FromBeginString(sessionID.BeginString), dataDictionary);
 }
Exemple #11
0
 protected void ProcessFixDataDictionary(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider, Stream dictionaryStream = null)
 {
     DataDictionary.DataDictionary dataDictionary = null;
     if (dictionaryStream != null)
     {
         dataDictionary = LoadDataDictionaryFromStream(settings, dictionaryStream);
     }
     else
     {
         dataDictionary = createDataDictionary(sessionID, settings, SessionSettings.DATA_DICTIONARY, sessionID.BeginString);
     }
     provider.AddTransportDataDictionary(sessionID.BeginString, dataDictionary);
     provider.AddApplicationDataDictionary(FixValues.ApplVerID.FromBeginString(sessionID.BeginString), dataDictionary);
 }
Exemple #12
0
        public Session Create(SessionID sessionID, QuickFix.Dictionary settings)
        {
            string connectionType = settings.GetString(SessionSettings.CONNECTION_TYPE);

            if (!"acceptor".Equals(connectionType) && !"initiator".Equals(connectionType))
            {
                throw new ConfigError("Invalid ConnectionType");
            }

            if ("acceptor".Equals(connectionType) && settings.Has(SessionSettings.SESSION_QUALIFIER))
            {
                throw new ConfigError("SessionQualifier cannot be used with acceptor.");
            }

            bool useDataDictionary = true;

            if (settings.Has(SessionSettings.USE_DATA_DICTIONARY))
            {
                useDataDictionary = settings.GetBool(SessionSettings.USE_DATA_DICTIONARY);
            }

            QuickFix.Fields.ApplVerID defaultApplVerID = null;
            if (sessionID.IsFIXT)
            {
                if (!settings.Has(SessionSettings.DEFAULT_APPLVERID))
                {
                    throw new ConfigError("ApplVerID is required for FIXT transport");
                }
                defaultApplVerID = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
            }

            DataDictionaryProvider dd = new DataDictionaryProvider();

            if (useDataDictionary)
            {
                if (sessionID.IsFIXT)
                {
                    ProcessFixTDataDictionaries(sessionID, settings, dd);
                }
                else
                {
                    ProcessFixDataDictionary(sessionID, settings, dd);
                }
            }

            int heartBtInt = 0;

            if (connectionType == "initiator")
            {
                heartBtInt = System.Convert.ToInt32(settings.GetLong(SessionSettings.HEARTBTINT));
                if (heartBtInt <= 0)
                {
                    throw new ConfigError("Heartbeat must be greater than zero");
                }
            }
            string senderDefaultApplVerId = "";

            if (defaultApplVerID != null)
            {
                senderDefaultApplVerId = defaultApplVerID.Obj;
            }

            Session session = new Session(
                application_,
                messageStoreFactory_,
                sessionID,
                dd,
                new SessionSchedule(settings),
                heartBtInt,
                logFactory_,
                messageFactory_,
                senderDefaultApplVerId);

            if (settings.Has(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS))
            {
                session.SendRedundantResendRequests = settings.GetBool(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS);
            }

            /** FIXME - implement optional settings
             * if (settings.Has(SessionSettings.CHECK_COMPID))
             *  session.SetCheckCompId(settings.GetBool(SessionSettings.CHECK_COMPID));
             * if (settings.Has(SessionSettings.CHECK_LATENCY))
             *  session.SetCheckLatency(settings.GetBool(SessionSettings.CHECK_LATENCY));
             * if (settings.Has(SessionSettings.MAX_LATENCY))
             *  session.SetMaxLatency(settings.GetLong(SessionSettings.MAX_LATENCY));
             */
            if (settings.Has(SessionSettings.LOGON_TIMEOUT))
            {
                session.LogonTimeout = settings.GetInt(SessionSettings.LOGON_TIMEOUT);
            }
            if (settings.Has(SessionSettings.LOGOUT_TIMEOUT))
            {
                session.LogoutTimeout = settings.GetInt(SessionSettings.LOGOUT_TIMEOUT);
            }

            // FIXME to get from config if available
            session.MaxLatency   = 120;
            session.CheckLatency = true;

            if (settings.Has(SessionSettings.RESET_ON_LOGON))
            {
                session.ResetOnLogon = settings.GetBool(SessionSettings.RESET_ON_LOGON);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGOUT))
            {
                session.ResetOnLogout = settings.GetBool(SessionSettings.RESET_ON_LOGOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_DISCONNECT))
            {
                session.ResetOnDisconnect = settings.GetBool(SessionSettings.RESET_ON_DISCONNECT);
            }
            if (settings.Has(SessionSettings.REFRESH_ON_LOGON))
            {
                session.RefreshOnLogon = settings.GetBool(SessionSettings.REFRESH_ON_LOGON);
            }
            if (settings.Has(SessionSettings.PERSIST_MESSAGES))
            {
                session.PersistMessages = settings.GetBool(SessionSettings.PERSIST_MESSAGES);
            }
            if (settings.Has(SessionSettings.MILLISECONDS_IN_TIMESTAMP))
            {
                session.MillisecondsInTimeStamp = settings.GetBool(SessionSettings.MILLISECONDS_IN_TIMESTAMP);
            }
            if (settings.Has(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED))
            {
                session.EnableLastMsgSeqNumProcessed = settings.GetBool(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED);
            }
            if (settings.Has(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST))
            {
                session.MaxMessagesInResendRequest = settings.GetInt(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST);
            }
            if (settings.Has(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT))
            {
                session.SendLogoutBeforeTimeoutDisconnect = settings.GetBool(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT);
            }
            if (settings.Has(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS))
            {
                session.IgnorePossDupResendRequests = settings.GetBool(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS);
            }

            /** FIXME - implement optional settings
             * if (settings.Has(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM))
             *  session.SetValidateLengthAndChecksum(settings.GetBool(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM));
             */
            if (settings.Has(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME))
            {
                session.RequiresOrigSendingTime = settings.GetBool(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME);
            }

            return(session);
        }
Exemple #13
0
        public Session Create(SessionID sessionID, QuickFix.Dictionary settings)
        {
            string connectionType = settings.GetString(SessionSettings.CONNECTION_TYPE);

            if (!"acceptor".Equals(connectionType) && !"initiator".Equals(connectionType))
            {
                throw new ConfigError("Invalid ConnectionType");
            }

            if ("acceptor".Equals(connectionType) && settings.Has(SessionSettings.SESSION_QUALIFIER))
            {
                throw new ConfigError("SessionQualifier cannot be used with acceptor.");
            }

            bool useDataDictionary = true;

            if (settings.Has(SessionSettings.USE_DATA_DICTIONARY))
            {
                useDataDictionary = settings.GetBool(SessionSettings.USE_DATA_DICTIONARY);
            }

            string defaultApplVerID = "";

            if (sessionID.IsFIXT)
            {
                throw new System.NotImplementedException("FIXME - SessionFactory cannot handle FIXT Sessions!");

                /*
                 * if (!settings.Has(SessionSettings.DEFAULT_APPLVERID))
                 * {
                 *  throw new ConfigError("ApplVerID is required for FIXT transport");
                 * }
                 * defaultApplVerID = Message.ToApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
                 */
            }

            DataDictionaryProvider dd = new DataDictionaryProvider();

            if (useDataDictionary)
            {
                if (sessionID.IsFIXT)
                {
                    throw new System.NotImplementedException("FIXME - SessionFactory cannot handle 'UseDataDictionary=Y' for 'FIXT' sessions!");
                }
                else
                {
                    ProcessFixDataDictionary(sessionID, settings, dd);
                }
            }

            int heartBtInt = 0;

            if (connectionType == "initiator")
            {
                heartBtInt = System.Convert.ToInt32(settings.GetLong(SessionSettings.HEARTBTINT));
                if (heartBtInt <= 0)
                {
                    throw new ConfigError("Heartbeat must be greater than zero");
                }
            }

            Session session = new Session(
                application_,
                messageStoreFactory_,
                sessionID,
                dd,
                new SessionSchedule(settings, sessionID),
                heartBtInt,
                logFactory_,
                new DefaultMessageFactory());

            session.SenderDefaultApplVerID = defaultApplVerID;

            /** FIXME - implement optional settings
             * if (settings.Has(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS))
             *  session.SetSendRedundantResendRequests(settings.GetBool(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS));
             * if (settings.Has(SessionSettings.CHECK_COMPID))
             *  session.SetCheckCompId(settings.GetBool(SessionSettings.CHECK_COMPID));
             * if (settings.Has(SessionSettings.CHECK_LATENCY))
             *  session.SetCheckLatency(settings.GetBool(SessionSettings.CHECK_LATENCY));
             * if (settings.Has(SessionSettings.MAX_LATENCY))
             *  session.SetMaxLatency(settings.GetLong(SessionSettings.MAX_LATENCY));
             * if (settings.Has(SessionSettings.LOGON_TIMEOUT))
             *  session.SetLogonTimeout(settings.GetLong(SessionSettings.LOGON_TIMEOUT));
             * if (settings.Has(SessionSettings.LOGOUT_TIMEOUT))
             *  session.SetLogoutTimeout(settings.GetLong(SessionSettings.LOGOUT_TIMEOUT));
             */

            // FIXME to get from config if available
            session.MaxLatency   = 120;
            session.CheckLatency = true;

            if (settings.Has(SessionSettings.RESET_ON_LOGON))
            {
                session.ResetOnLogon = settings.GetBool(SessionSettings.RESET_ON_LOGON);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGOUT))
            {
                session.ResetOnLogout = settings.GetBool(SessionSettings.RESET_ON_LOGOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_DISCONNECT))
            {
                session.ResetOnDisconnect = settings.GetBool(SessionSettings.RESET_ON_DISCONNECT);
            }
            if (settings.Has(SessionSettings.REFRESH_ON_LOGON))
            {
                session.RefreshOnLogon = settings.GetBool(SessionSettings.REFRESH_ON_LOGON);
            }

            /** FIXME - implement optional settings
             * if (settings.Has(SessionSettings.MILLISECONDS_IN_TIMESTAMP))
             *  session.SetMillisecondsInTimeStamp(settings.GetBool(SessionSettings.MILLISECONDS_IN_TIMESTAMP));
             * if (settings.Has(SessionSettings.PERSIST_MESSAGES))
             *  session.SetPersistMessages(settings.GetBool(SessionSettings.PERSIST_MESSAGES));
             * if (settings.Has(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM))
             *  session.SetValidateLengthAndChecksum(settings.GetBool(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM));
             */

            return(session);
        }
Exemple #14
0
 protected void ProcessFixDataDictionary(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider)
 {
     DataDictionary.DataDictionary dataDictionary = createDataDictionary(sessionID, settings, SessionSettings.DATA_DICTIONARY, sessionID.BeginString);
     provider.AddTransportDataDictionary(sessionID.BeginString, dataDictionary);
     provider.AddApplicationDataDictionary(FixValues.ApplVerID.FromBeginString(sessionID.BeginString), dataDictionary);
 }
        public Session Create(SessionID sessionID, QuickFix.Dictionary settings)
        {
            string connectionType = settings.GetString(SessionSettings.CONNECTION_TYPE);
            if (!"acceptor".Equals(connectionType) && !"initiator".Equals(connectionType))
                throw new ConfigError("Invalid ConnectionType");

            if ("acceptor".Equals(connectionType) && settings.Has(SessionSettings.SESSION_QUALIFIER))
                throw new ConfigError("SessionQualifier cannot be used with acceptor.");

            bool useDataDictionary = true;
            if (settings.Has(SessionSettings.USE_DATA_DICTIONARY))
                useDataDictionary = settings.GetBool(SessionSettings.USE_DATA_DICTIONARY);

            string defaultApplVerID = "";
            if (sessionID.IsFIXT)
            {
                throw new System.NotImplementedException("FIXME - SessionFactory cannot handle FIXT Sessions!");
                /*
                if (!settings.Has(SessionSettings.DEFAULT_APPLVERID))
                {
                    throw new ConfigError("ApplVerID is required for FIXT transport");
                }
                defaultApplVerID = Message.ToApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
                */
            }

            DataDictionaryProvider dd = new DataDictionaryProvider();
            if (useDataDictionary)
            {
                if (sessionID.IsFIXT)
                    throw new System.NotImplementedException("FIXME - SessionFactory cannot handle 'UseDataDictionary=Y' for 'FIXT' sessions!");
                else
                    ProcessFixDataDictionary(sessionID, settings, dd);
            }

            int heartBtInt = 0;
            if ( connectionType == "initiator" )
            {
                heartBtInt = System.Convert.ToInt32(settings.GetLong( SessionSettings.HEARTBTINT ));
                if ( heartBtInt <= 0 )
                    throw new ConfigError( "Heartbeat must be greater than zero" );
            }

            Session session = new Session(
                application_,
                messageStoreFactory_,
                sessionID,
                dd,
                new SessionSchedule(settings, sessionID),
                heartBtInt,
                logFactory_,
                new DefaultMessageFactory());
            session.SenderDefaultApplVerID = defaultApplVerID;

            /** FIXME - implement optional settings
            if (settings.Has(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS))
                session.SetSendRedundantResendRequests(settings.GetBool(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS));
            if (settings.Has(SessionSettings.CHECK_COMPID))
                session.SetCheckCompId(settings.GetBool(SessionSettings.CHECK_COMPID));
            if (settings.Has(SessionSettings.CHECK_LATENCY))
                session.SetCheckLatency(settings.GetBool(SessionSettings.CHECK_LATENCY));
            if (settings.Has(SessionSettings.MAX_LATENCY))
                session.SetMaxLatency(settings.GetLong(SessionSettings.MAX_LATENCY));
            if (settings.Has(SessionSettings.LOGON_TIMEOUT))
                session.SetLogonTimeout(settings.GetLong(SessionSettings.LOGON_TIMEOUT));
            if (settings.Has(SessionSettings.LOGOUT_TIMEOUT))
                session.SetLogoutTimeout(settings.GetLong(SessionSettings.LOGOUT_TIMEOUT));
            */

            // FIXME to get from config if available
            session.MaxLatency = 120;
            session.CheckLatency = true;

            if (settings.Has(SessionSettings.RESET_ON_LOGON))
                session.ResetOnLogon = settings.GetBool(SessionSettings.RESET_ON_LOGON);
            if (settings.Has(SessionSettings.RESET_ON_LOGOUT))
                session.ResetOnLogout = settings.GetBool(SessionSettings.RESET_ON_LOGOUT);
            if (settings.Has(SessionSettings.RESET_ON_DISCONNECT))
                session.ResetOnDisconnect = settings.GetBool(SessionSettings.RESET_ON_DISCONNECT);
            if (settings.Has(SessionSettings.REFRESH_ON_LOGON))
                session.RefreshOnLogon = settings.GetBool(SessionSettings.REFRESH_ON_LOGON);
            /** FIXME - implement optional settings
            if (settings.Has(SessionSettings.MILLISECONDS_IN_TIMESTAMP))
                session.SetMillisecondsInTimeStamp(settings.GetBool(SessionSettings.MILLISECONDS_IN_TIMESTAMP));
            if (settings.Has(SessionSettings.PERSIST_MESSAGES))
                session.SetPersistMessages(settings.GetBool(SessionSettings.PERSIST_MESSAGES));
            if (settings.Has(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM))
                session.SetValidateLengthAndChecksum(settings.GetBool(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM));
            */

            return session;
        }
Exemple #16
0
        public Session Create(SessionID sessionID, QuickFix.Dictionary settings)
        {
            string connectionType = settings.GetString(SessionSettings.CONNECTION_TYPE);

            if (!"acceptor".Equals(connectionType) && !"initiator".Equals(connectionType))
            {
                throw new ConfigError("Invalid ConnectionType");
            }

            if ("acceptor".Equals(connectionType) && settings.Has(SessionSettings.SESSION_QUALIFIER))
            {
                throw new ConfigError("SessionQualifier cannot be used with acceptor.");
            }

            bool useDataDictionary = true;

            if (settings.Has(SessionSettings.USE_DATA_DICTIONARY))
            {
                useDataDictionary = settings.GetBool(SessionSettings.USE_DATA_DICTIONARY);
            }

            QuickFix.Fields.ApplVerID defaultApplVerID  = null;
            IMessageFactory           sessionMsgFactory = messageFactory_;

            if (sessionID.IsFIXT)
            {
                if (!settings.Has(SessionSettings.DEFAULT_APPLVERID))
                {
                    throw new ConfigError("ApplVerID is required for FIXT transport");
                }
                string rawDefaultApplVerIdSetting = settings.GetString(SessionSettings.DEFAULT_APPLVERID);

                defaultApplVerID = Message.GetApplVerID(rawDefaultApplVerIdSetting);

                // DefaultMessageFactory as created in the SessionFactory ctor cannot
                // tell the difference between FIX50 versions (same BeginString, unknown defaultApplVerId).
                // But we have the real session settings here, so we can fix that.
                // This is, of course, kind of a hack, and it should be reworked in V2 (TODO!).
                if (messageFactory_ is DefaultMessageFactory)
                {
                    sessionMsgFactory = new DefaultMessageFactory(
                        FixValues.ApplVerID.FromBeginString(rawDefaultApplVerIdSetting));
                }
            }

            DataDictionaryProvider dd = new DataDictionaryProvider();

            if (useDataDictionary)
            {
                if (sessionID.IsFIXT)
                {
                    ProcessFixTDataDictionaries(sessionID, settings, dd);
                }
                else
                {
                    ProcessFixDataDictionary(sessionID, settings, dd);
                }
            }

            int heartBtInt = 0;

            if (connectionType == "initiator")
            {
                heartBtInt = System.Convert.ToInt32(settings.GetLong(SessionSettings.HEARTBTINT));
                if (heartBtInt <= 0)
                {
                    throw new ConfigError("Heartbeat must be greater than zero");
                }
            }
            string senderDefaultApplVerId = "";

            if (defaultApplVerID != null)
            {
                senderDefaultApplVerId = defaultApplVerID.Obj;
            }

            Session session = new Session(
                application_,
                messageStoreFactory_,
                sessionID,
                dd,
                new SessionSchedule(settings),
                heartBtInt,
                logFactory_,
                sessionMsgFactory,
                senderDefaultApplVerId);

            if (settings.Has(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS))
            {
                session.SendRedundantResendRequests = settings.GetBool(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS);
            }
            if (settings.Has(SessionSettings.RESEND_SESSION_LEVEL_REJECTS))
            {
                session.ResendSessionLevelRejects = settings.GetBool(SessionSettings.RESEND_SESSION_LEVEL_REJECTS);
            }

            /* FIXME - implement optional settings
             * if (settings.Has(SessionSettings.CHECK_COMPID))
             *  session.SetCheckCompId(settings.GetBool(SessionSettings.CHECK_COMPID));
             */
            if (settings.Has(SessionSettings.CHECK_LATENCY))
            {
                session.CheckLatency = settings.GetBool(SessionSettings.CHECK_LATENCY);
            }
            if (settings.Has(SessionSettings.MAX_LATENCY))
            {
                session.MaxLatency = settings.GetInt(SessionSettings.MAX_LATENCY);
            }
            if (settings.Has(SessionSettings.LOGON_TIMEOUT))
            {
                session.LogonTimeout = settings.GetInt(SessionSettings.LOGON_TIMEOUT);
            }
            if (settings.Has(SessionSettings.LOGOUT_TIMEOUT))
            {
                session.LogoutTimeout = settings.GetInt(SessionSettings.LOGOUT_TIMEOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGON))
            {
                session.ResetOnLogon = settings.GetBool(SessionSettings.RESET_ON_LOGON);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGOUT))
            {
                session.ResetOnLogout = settings.GetBool(SessionSettings.RESET_ON_LOGOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_DISCONNECT))
            {
                session.ResetOnDisconnect = settings.GetBool(SessionSettings.RESET_ON_DISCONNECT);
            }
            if (settings.Has(SessionSettings.REFRESH_ON_LOGON))
            {
                session.RefreshOnLogon = settings.GetBool(SessionSettings.REFRESH_ON_LOGON);
            }
            if (settings.Has(SessionSettings.PERSIST_MESSAGES))
            {
                session.PersistMessages = settings.GetBool(SessionSettings.PERSIST_MESSAGES);
            }
            if (settings.Has(SessionSettings.MILLISECONDS_IN_TIMESTAMP))
            {
                session.MillisecondsInTimeStamp = settings.GetBool(SessionSettings.MILLISECONDS_IN_TIMESTAMP);
            }
            if (settings.Has(SessionSettings.TIMESTAMP_PRECISION))
            {
                session.TimeStampPrecision = settings.GetTimeStampPrecision(SessionSettings.TIMESTAMP_PRECISION);
            }
            if (settings.Has(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED))
            {
                session.EnableLastMsgSeqNumProcessed = settings.GetBool(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED);
            }
            if (settings.Has(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST))
            {
                session.MaxMessagesInResendRequest = settings.GetInt(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST);
            }
            if (settings.Has(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT))
            {
                session.SendLogoutBeforeTimeoutDisconnect = settings.GetBool(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT);
            }
            if (settings.Has(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS))
            {
                session.IgnorePossDupResendRequests = settings.GetBool(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS);
            }
            if (settings.Has(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM))
            {
                session.ValidateLengthAndChecksum = settings.GetBool(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM);
            }
            if (settings.Has(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME))
            {
                session.RequiresOrigSendingTime = settings.GetBool(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME);
            }

            return(session);
        }
Exemple #17
0
 /// TODO need to make deeper copy?
 public DataDictionaryProvider(DataDictionaryProvider src)
 {
     transportDataDictionaries_   = new Dictionary <string, DataDictionary.DataDictionary>(src.transportDataDictionaries_);
     applicationDataDictionaries_ = new Dictionary <string, DataDictionary.DataDictionary>(src.applicationDataDictionaries_);
     emptyDataDictionary_         = new DataDictionary.DataDictionary(src.emptyDataDictionary_);
 }