public Create ( |
||
sessionID | ||
settings | QuickFix | |
리턴 |
public void Start() { if (_disposed) { throw new System.ObjectDisposedException(this.GetType().Name); } // create all sessions SessionFactory factory = new SessionFactory(_app, _storeFactory, _logFactory, _msgFactory); foreach (SessionID sessionID in _settings.GetSessions()) { Dictionary dict = _settings.Get(sessionID); sessionIDs_.Add(sessionID); sessions_[sessionID] = factory.Create(sessionID, dict); SetDisconnected(sessionID); } if (0 == sessions_.Count) { throw new ConfigError("No sessions defined for initiator"); } // start it up isStopped_ = false; OnConfigure(_settings); thread_ = new Thread(new ThreadStart(OnStart)); thread_.Start(); }
public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory) { settings_ = settings; HashSet <SessionID> definedSessions = settings.GetSessions(); if (0 == definedSessions.Count) { throw new ConfigError("No sessions defined"); } SessionFactory factory = new SessionFactory(app, storeFactory, logFactory, messageFactory); foreach (SessionID sessionID in definedSessions) { Dictionary dict = settings.Get(sessionID); if ("initiator".Equals(dict.GetString(SessionSettings.CONNECTION_TYPE))) { sessionIDs_.Add(sessionID); sessions_[sessionID] = factory.Create(sessionID, dict); SetDisconnected(sessionID); } } if (0 == sessions_.Count) { throw new ConfigError("No sessions defined for initiator"); } }
public void TestPersistMessages() { IApplication app = new NullApplication(); IMessageStoreFactory storeFactory = new MemoryStoreFactory(); SessionFactory factory = new SessionFactory(app, storeFactory); SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET"); Dictionary settings = new Dictionary(); settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N"); settings.SetString(SessionSettings.CONNECTION_TYPE, "initiator"); settings.SetString(SessionSettings.HEARTBTINT, "30"); settings.SetString(SessionSettings.START_TIME, "12:00:00"); settings.SetString(SessionSettings.END_TIME, "12:00:00"); Session session = factory.Create(sessionID, settings); //true by default Assert.That(session.PersistMessages); settings.SetBool(SessionSettings.PERSIST_MESSAGES, false); session = factory.Create(sessionID, settings); Assert.That(!session.PersistMessages); }
/// <summary> /// Create session, either at start-up or as an ad-hoc operation /// </summary> /// <param name="sessionID">ID of new session</param> /// <param name="dict">config settings for new session</param> /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns> private bool CreateSession(SessionID sessionID, Dictionary dict) { if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID)) { Session session = sessionFactory_.Create(sessionID, dict); lock (sync_) { sessionIDs_.Add(sessionID); sessions_[sessionID] = session; SetDisconnected(sessionID); } return(true); } return(false); }
/// <summary> /// Create session, either at start-up or as an ad-hoc operation /// </summary> /// <param name="sessionID">ID of new session<param> /// <param name="dict">config settings for new session</param></param> /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns> private bool CreateSession(SessionID sessionID, Dictionary dict) { if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID)) { Session session = sessionFactory_.Create(sessionID, dict); lock (GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable) { sessionIDs_.Add(sessionID); sessions_[sessionID] = session; SetDisconnected(sessionID); } return(true); } return(false); }
public void TestExtendedSettings() { Application app = new NullApplication(); MessageStoreFactory storeFactory = new MemoryStoreFactory(); SessionFactory factory = new SessionFactory(app, storeFactory); SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET"); Dictionary settings = new Dictionary(); settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N"); settings.SetString(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS, "Y"); settings.SetString(SessionSettings.MILLISECONDS_IN_TIMESTAMP, "Y"); settings.SetString(SessionSettings.CONNECTION_TYPE, "initiator"); settings.SetString(SessionSettings.HEARTBTINT, "30"); settings.SetString(SessionSettings.START_TIME, "12:00:00"); settings.SetString(SessionSettings.END_TIME, "12:00:00"); settings.SetString(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED, "Y"); settings.SetString(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST, "2500"); settings.SetString(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT, "Y"); settings.SetString(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS, "Y"); Session session = factory.Create(sessionID, settings); Assert.That(session.SendRedundantResendRequests); Assert.That(session.MillisecondsInTimeStamp); settings.SetString(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS, "N"); settings.SetString(SessionSettings.MILLISECONDS_IN_TIMESTAMP, "N"); session = factory.Create(sessionID, settings); Assert.That(!session.SendRedundantResendRequests); Assert.That(!session.MillisecondsInTimeStamp); Assert.That(session.EnableLastMsgSeqNumProcessed); Assert.That(session.MaxMessagesInResendRequest, Is.EqualTo(2500)); Assert.That(session.SendLogoutBeforeTimeoutDisconnect); Assert.That(session.IgnorePossDupResendRequests); }
/// <summary> /// Create session, either at start-up or as an ad-hoc operation /// </summary> /// <param name="sessionID">ID of new session</param> /// <param name="dict">config settings for new session</param> /// <returns>true if session added successfully, false if session already exists or is not an acceptor</returns> private bool CreateSession(SessionID sessionID, Dictionary dict) { if (!sessions_.ContainsKey(sessionID)) { string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE); if ("acceptor" == connectionType) { AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(dict); Session session = sessionFactory_.Create(sessionID, dict); descriptor.AcceptSession(session); sessions_[sessionID] = session; return(true); } } return(false); }
public void ValidConfiguration() { Application app = new NullApplication(); MessageStoreFactory storeFactory = new MemoryStoreFactory(); SessionFactory factory = new SessionFactory(app, storeFactory); SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET"); Dictionary settings = new Dictionary(); settings.SetString(SessionSettings.CONNECTION_TYPE, "initiator"); settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N"); settings.SetString(SessionSettings.START_TIME, "12:00:00"); settings.SetString(SessionSettings.END_TIME, "12:00:00"); settings.SetString(SessionSettings.HEARTBTINT, "30"); Assert.DoesNotThrow(delegate { factory.Create(sessionID, settings); }); }
/// <summary> /// Add new session, either at start-up or as an ad-hoc operation /// </summary> /// <param name="sessionID">ID of new session<param> /// <param name="dict">config settings for new session</param></param> /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns> public bool AddSession(SessionID sessionID, Dictionary dict) { if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID)) { Session session = sessionFactory_.Create(sessionID, dict); lock (sync_) { if (!_settings.Has(sessionID)) // session won't be in settings if ad-hoc creation after startup { _settings.Set(sessionID, dict); } sessionIDs_.Add(sessionID); sessions_[sessionID] = session; SetDisconnected(sessionID); } return(true); } return(false); }
private void CreateSessions(SessionSettings settings) { foreach (SessionID sessionID in settings.GetSessions()) { QuickFix.Dictionary dict = settings.Get(sessionID); string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE); if ("acceptor".Equals(connectionType)) { AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(settings, sessionID); Session session = sessionFactory_.Create(sessionID, dict); descriptor.AcceptSession(session); sessions_[sessionID] = session; } } if (0 == socketDescriptorForAddress_.Count) { throw new ConfigError("No acceptor sessions found in SessionSettings."); } }
public AbstractInitiator(SessionFactory factory, SessionSettings settings) { settings_ = settings; HashSet<SessionID> definedSessions = settings.GetSessions(); if (0 == definedSessions.Count) throw new ConfigError("No sessions defined"); foreach (SessionID sessionID in definedSessions) { Dictionary dict = settings.Get(sessionID); if ("initiator".Equals(dict.GetString(SessionSettings.CONNECTION_TYPE))) { sessionIDs_.Add(sessionID); sessions_[sessionID] = factory.Create(sessionID, dict); SetDisconnected(sessionID); } } if (0 == sessions_.Count) throw new ConfigError("No sessions defined for initiator"); }
/// <summary> /// Create session, either at start-up or as an ad-hoc operation /// </summary> /// <param name="sessionID">ID of new session</param> /// <param name="dict">config settings for new session</param> /// <returns>true if session added successfully, false if session already exists or is not an acceptor</returns> private bool CreateSession(SessionID sessionID, Dictionary dict) { if (!sessions_.ContainsKey(sessionID)) { string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE); if ("acceptor" == connectionType) { AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(dict); Session session = sessionFactory_.Create(sessionID, dict); // start descriptor if it was just created and if acceptor is already started if (isStarted_ && !_disposed && !descriptor.SocketReactor.IsStarted) { descriptor.SocketReactor.Start(); } descriptor.AcceptSession(session); sessions_[sessionID] = session; return(true); } } return(false); }
private void CreateSessions(SessionSettings settings, SessionFactory sessionFactory) { foreach (SessionID sessionID in settings.GetSessions()) { QuickFix.Dictionary dict = settings.Get(sessionID); string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE); if ("acceptor".Equals(connectionType)) { AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(settings, sessionID); Session session = sessionFactory.Create(sessionID, dict); descriptor.AcceptSession(session); sessions_[sessionID] = session; } } if (0 == socketDescriptorForAddress_.Count) throw new ConfigError("No acceptor sessions found in SessionSettings."); }
public void Start() { if (_disposed) throw new System.ObjectDisposedException(this.GetType().Name); // create all sessions SessionFactory factory = new SessionFactory(_app, _storeFactory, _logFactory, _msgFactory); foreach (SessionID sessionID in _settings.GetSessions()) { Dictionary dict = _settings.Get(sessionID); sessionIDs_.Add(sessionID); sessions_[sessionID] = factory.Create(sessionID, dict, _dictionaryStream); SetDisconnected(sessionID); } if (0 == sessions_.Count) throw new ConfigError("No sessions defined for initiator"); // start it up isStopped_ = false; OnConfigure(_settings); thread_ = new Thread(new ThreadStart(OnStart)); thread_.Start(); }