internal ClientHandlerThread(TcpClient tcpClient, long clientId, QuickFix.Dictionary settingsDict, SocketSettings socketSettings, AcceptorSocketDescriptor acceptorDescriptor ) { string debugLogFilePath = "log"; if (settingsDict.Has(SessionSettings.DEBUG_FILE_LOG_PATH)) { debugLogFilePath = settingsDict.GetString(SessionSettings.DEBUG_FILE_LOG_PATH); } else if (settingsDict.Has(SessionSettings.FILE_LOG_PATH)) { debugLogFilePath = settingsDict.GetString(SessionSettings.FILE_LOG_PATH); } var sessionId = new SessionID("ClientHandlerThread", clientId.ToString(), "Debug"); try { // FIXME - do something more flexible than hardcoding a filelog log_ = new FileLog(debugLogFilePath, sessionId); } catch { // TODO: fix this the correct way log_ = new ScreenLog(sessionId, true, true, true); } this.Id = clientId; socketReader_ = new SocketReader(tcpClient, socketSettings, this, acceptorDescriptor); }
/// <summary> /// </summary> /// <param name="settings"></param> public SessionSchedule(QuickFix.Dictionary settings) { if (settings.Has(SessionSettings.NON_STOP_SESSION)) { NonStopSession = settings.GetBool(SessionSettings.NON_STOP_SESSION); } if (NonStopSession) { return; } if (!settings.Has(SessionSettings.START_DAY) && settings.Has(SessionSettings.END_DAY)) { throw new QuickFix.ConfigError("EndDay used without StartDay"); } if (settings.Has(SessionSettings.START_DAY) && !settings.Has(SessionSettings.END_DAY)) { throw new QuickFix.ConfigError("StartDay used without EndDay"); } if (settings.Has(SessionSettings.START_DAY) && settings.Has(SessionSettings.END_DAY)) { StartDay = settings.GetDay(SessionSettings.START_DAY); EndDay = settings.GetDay(SessionSettings.END_DAY); WeeklySession = true; } if (settings.Has(SessionSettings.USE_LOCAL_TIME)) { UseLocalTime = settings.GetBool(SessionSettings.USE_LOCAL_TIME); } if (settings.Has(SessionSettings.TIME_ZONE)) { if (UseLocalTime) { throw new ConfigError( SessionSettings.TIME_ZONE + " conflicts with " + SessionSettings.USE_LOCAL_TIME); } string id = settings.GetString(SessionSettings.TIME_ZONE); TimeZone = System.TimeZoneInfo.FindSystemTimeZoneById(id); } try { this.StartTime = System.TimeSpan.Parse( settings.GetString(SessionSettings.START_TIME)); this.EndTime = System.TimeSpan.Parse( settings.GetString(SessionSettings.END_TIME)); } catch (System.FormatException e) { throw new ConfigError(e.Message); } }
private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(SessionSettings settings, SessionID sessionID) { QuickFix.Dictionary dict = settings_.Get(sessionID); int port = System.Convert.ToInt32(dict.GetLong(SessionSettings.SOCKET_ACCEPT_PORT)); SocketSettings socketSettings = new SocketSettings(); IPEndPoint socketEndPoint; if (dict.Has(SessionSettings.SOCKET_ACCEPT_HOST)) { string host = dict.GetString(SessionSettings.SOCKET_ACCEPT_HOST); IPAddress[] addrs = Dns.GetHostAddresses(host); socketEndPoint = new IPEndPoint(addrs[0], port); } else { socketEndPoint = new IPEndPoint(IPAddress.Any, port); } if (dict.Has(SessionSettings.SOCKET_NODELAY)) { socketSettings.SocketNodelay = dict.GetBool(SessionSettings.SOCKET_NODELAY); } AcceptorSocketDescriptor descriptor; if (!socketDescriptorForAddress_.TryGetValue(socketEndPoint, out descriptor)) { descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict); socketDescriptorForAddress_[socketEndPoint] = descriptor; } return(descriptor); }
public override string ToString() { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.AppendLine("[DEFAULT]"); foreach (System.Collections.Generic.KeyValuePair <string, string> entry in defaults_) { s.Append(entry.Key).Append('=').AppendLine(entry.Value); } foreach (KeyValuePair <SessionID, QuickFix.Dictionary> entry in settings_) { s.AppendLine().AppendLine("[SESSION]"); foreach (System.Collections.Generic.KeyValuePair <string, string> kvp in entry.Value) { if (defaults_.Has(kvp.Key) && defaults_.GetString(kvp.Key).Equals(kvp.Value)) { continue; } s.Append(kvp.Key).Append('=').AppendLine(kvp.Value); } } return(s.ToString()); }
private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(SessionSettings settings, SessionID sessionID) { QuickFix.Dictionary dict = settings.Get(sessionID); int port = System.Convert.ToInt32(dict.GetLong(SessionSettings.SOCKET_ACCEPT_PORT)); SocketSettings socketSettings = new SocketSettings(); IPEndPoint socketEndPoint; if (dict.Has(SessionSettings.SOCKET_ACCEPT_HOST)) { string host = dict.GetString(SessionSettings.SOCKET_ACCEPT_HOST); IPAddress[] addrs = Dns.GetHostAddresses(host); socketEndPoint = new IPEndPoint(addrs[0], port); // Set hostname (if it is not already configured) socketSettings.ServerCommonName = socketSettings.ServerCommonName ?? host; } else { socketEndPoint = new IPEndPoint(IPAddress.Any, port); } socketSettings.Configure(dict); AcceptorSocketDescriptor descriptor; if (!socketDescriptorForAddress_.TryGetValue(socketEndPoint, out descriptor)) { descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict); socketDescriptorForAddress_[socketEndPoint] = descriptor; } return(descriptor); }
protected DataDictionary.DataDictionary createDataDictionary(SessionID sessionID, QuickFix.Dictionary settings, string settingsKey, string beginString) { DataDictionary.DataDictionary dd; string path; if (settings.Has(settingsKey)) path = settings.GetString(settingsKey); else path = beginString.Replace(".", "") + ".xml"; if (!dictionariesByPath_.TryGetValue(path, out dd)) { dd = new DataDictionary.DataDictionary(path); dictionariesByPath_[path] = dd; } DataDictionary.DataDictionary ddCopy = new DataDictionary.DataDictionary(dd); if (settings.Has(SessionSettings.VALIDATE_FIELDS_OUT_OF_ORDER)) ddCopy.CheckFieldsOutOfOrder = settings.GetBool(SessionSettings.VALIDATE_FIELDS_OUT_OF_ORDER); if (settings.Has(SessionSettings.VALIDATE_FIELDS_HAVE_VALUES)) ddCopy.CheckFieldsHaveValues = settings.GetBool(SessionSettings.VALIDATE_FIELDS_HAVE_VALUES); if (settings.Has(SessionSettings.VALIDATE_USER_DEFINED_FIELDS)) ddCopy.CheckUserDefinedFields = settings.GetBool(SessionSettings.VALIDATE_USER_DEFINED_FIELDS); if (settings.Has(SessionSettings.ALLOW_UNKNOWN_MSG_FIELDS)) ddCopy.AllowUnknownMessageFields = settings.GetBool(SessionSettings.ALLOW_UNKNOWN_MSG_FIELDS); return ddCopy; }
private IPEndPoint GetNextSocketEndPoint(SessionID sessionID, QuickFix.Dictionary settings) { int num; if (!sessionToHostNum_.TryGetValue(sessionID, out num)) { num = 0; } string hostKey = SessionSettings.SOCKET_CONNECT_HOST + num; string portKey = SessionSettings.SOCKET_CONNECT_PORT + num; if (!settings.Has(hostKey) || !settings.Has(portKey)) { num = 0; hostKey = SessionSettings.SOCKET_CONNECT_HOST; portKey = SessionSettings.SOCKET_CONNECT_PORT; } try { var hostName = settings.GetString(hostKey); IPAddress[] addrs = Dns.GetHostAddresses(hostName); int port = System.Convert.ToInt32(settings.GetLong(portKey)); sessionToHostNum_[sessionID] = ++num; socketSettings_.ServerCommonName = hostName; return(new IPEndPoint(addrs.First(a => a.AddressFamily == AddressFamily.InterNetwork), port)); } catch (System.Exception e) { throw new ConfigError(e.Message, e); } }
protected DataDictionary.DataDictionary createDataDictionary(SessionID sessionID, QuickFix.Dictionary settings, string settingsKey) { DataDictionary.DataDictionary dd; string path = settings.GetString(settingsKey); if (!dictionariesByPath_.TryGetValue(path, out dd)) { dd = new DataDictionary.DataDictionary(path); dictionariesByPath_[path] = dd; } DataDictionary.DataDictionary ddCopy = new DataDictionary.DataDictionary(dd); if (settings.Has(SessionSettings.VALIDATE_FIELDS_OUT_OF_ORDER)) { ddCopy.CheckFieldsOutOfOrder = settings.GetBool(SessionSettings.VALIDATE_FIELDS_OUT_OF_ORDER); } if (settings.Has(SessionSettings.VALIDATE_FIELDS_HAVE_VALUES)) { ddCopy.CheckFieldsHaveValues = settings.GetBool(SessionSettings.VALIDATE_FIELDS_HAVE_VALUES); } if (settings.Has(SessionSettings.VALIDATE_USER_DEFINED_FIELDS)) { ddCopy.CheckUserDefinedFields = settings.GetBool(SessionSettings.VALIDATE_USER_DEFINED_FIELDS); } return(ddCopy); }
static private bool DetectIfInitiator(QuickFix.Dictionary settings) { switch (settings.GetString(SessionSettings.CONNECTION_TYPE)) { case "acceptor": return false; case "initiator": return true; } throw new ConfigError("Invalid ConnectionType"); }
/// <summary> /// Creates a ClientHandlerThread /// </summary> /// <param name="tcpClient"></param> /// <param name="clientId"></param> /// <param name="debugLogFilePath">path where thread log will go</param> public ClientHandlerThread(TcpClient tcpClient, long clientId, QuickFix.Dictionary settingsDict, SocketSettings socketSettings) { string debugLogFilePath = "log"; if (settingsDict.Has(SessionSettings.DEBUG_FILE_LOG_PATH)) { debugLogFilePath = settingsDict.GetString(SessionSettings.DEBUG_FILE_LOG_PATH); } else if (settingsDict.Has(SessionSettings.FILE_LOG_PATH)) { debugLogFilePath = settingsDict.GetString(SessionSettings.FILE_LOG_PATH); } // FIXME - do something more flexible than hardcoding a filelog log_ = new FileLog(debugLogFilePath, new SessionID("ClientHandlerThread", clientId.ToString(), "Debug")); this.Id = clientId; socketReader_ = new SocketReader(tcpClient, socketSettings, this); }
protected void Validate(QuickFix.Dictionary dictionary) { string beginString = dictionary.GetString(BEGINSTRING); if (beginString != Values.BeginString_FIX40 && beginString != Values.BeginString_FIX41 && beginString != Values.BeginString_FIX42 && beginString != Values.BeginString_FIX43 && beginString != Values.BeginString_FIX44 && beginString != Values.BeginString_FIXT11) { throw new ConfigError(BEGINSTRING + " (" + beginString + ") must be FIX.4.0 to FIX.4.4 or FIXT.1.1"); } string connectionType = dictionary.GetString(CONNECTION_TYPE); if (!"initiator".Equals(connectionType) && !"acceptor".Equals(connectionType)) { throw new ConfigError(CONNECTION_TYPE + " must be 'initiator' or 'acceptor'"); } }
internal ClientHandlerThread(TcpClient tcpClient, long clientId, QuickFix.Dictionary settingsDict, SocketSettings socketSettings, AcceptorSocketDescriptor acceptorDescriptor) { string debugLogFilePath = "log"; if (settingsDict.Has(SessionSettings.DEBUG_FILE_LOG_PATH)) { debugLogFilePath = settingsDict.GetString(SessionSettings.DEBUG_FILE_LOG_PATH); } else if (settingsDict.Has(SessionSettings.FILE_LOG_PATH)) { debugLogFilePath = settingsDict.GetString(SessionSettings.FILE_LOG_PATH); } // FIXME - do something more flexible than hardcoding a filelog log_ = new FileLog(debugLogFilePath, new SessionID( "ClientHandlerThread", clientId.ToString(), "Debug-" + Guid.NewGuid().ToString())); this.Id = clientId; this.SourceAddress = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString(); socketReader_ = new SocketReader(tcpClient, socketSettings, this, acceptorDescriptor); }
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."); } }
internal ClientHandlerThread(TcpClient tcpClient, long clientId, QuickFix.Dictionary settingsDict, SocketSettings socketSettings, AcceptorSocketDescriptor acceptorDescriptor) { string debugLogFilePath = ""; if (settingsDict.Has(SessionSettings.DEBUG_FILE_LOG_PATH)) { debugLogFilePath = settingsDict.GetString(SessionSettings.DEBUG_FILE_LOG_PATH); } //else if (settingsDict.Has(SessionSettings.FILE_LOG_PATH)) // debugLogFilePath = settingsDict.GetString(SessionSettings.FILE_LOG_PATH); // FIXME - do something more flexible than hardcoding a filelog if (!string.IsNullOrEmpty(debugLogFilePath)) { log_ = new FileLog(debugLogFilePath, new SessionID( "ClientHandlerThread", clientId.ToString(), "Debug-" + Guid.NewGuid().ToString())); } this.Id = clientId; socketReader_ = new SocketReader(tcpClient, socketSettings, this, acceptorDescriptor); }
/// <summary> /// Setup socket settings based on setttings specified in dictionary /// </summary> /// <remarks> /// used "Configure" as name since it is used in a lot of other places, /// alternative names are ReadSettings or FromDictionary /// </remarks> /// <param name="dictionary">the dictionary to read the settings from</param> public void Configure(QuickFix.Dictionary dictionary) { if (dictionary.Has(SessionSettings.SOCKET_NODELAY)) { SocketNodelay = dictionary.GetBool(SessionSettings.SOCKET_NODELAY); } if (dictionary.Has(SessionSettings.SOCKET_RECEIVE_BUFFER_SIZE)) { SocketReceiveBufferSize = dictionary.GetInt(SessionSettings.SOCKET_RECEIVE_BUFFER_SIZE); } if (dictionary.Has(SessionSettings.SOCKET_SEND_BUFFER_SIZE)) { SocketSendBufferSize = dictionary.GetInt(SessionSettings.SOCKET_SEND_BUFFER_SIZE); } if (dictionary.Has(SessionSettings.SSL_SERVERNAME)) { ServerCommonName = dictionary.GetString(SessionSettings.SSL_SERVERNAME); } if (dictionary.Has(SessionSettings.SSL_CA_CERTIFICATE)) { CACertificatePath = dictionary.GetString(SessionSettings.SSL_CA_CERTIFICATE); } if (dictionary.Has(SessionSettings.SSL_CERTIFICATE)) { CertificatePath = dictionary.GetString(SessionSettings.SSL_CERTIFICATE); } if (dictionary.Has(SessionSettings.SSL_CERTIFICATE_PASSWORD)) { CertificatePassword = dictionary.GetString(SessionSettings.SSL_CERTIFICATE_PASSWORD); } if (dictionary.Has(SessionSettings.SSL_VALIDATE_CERTIFICATES)) { ValidateCertificates = dictionary.GetBool(SessionSettings.SSL_VALIDATE_CERTIFICATES); } if (dictionary.Has(SessionSettings.SSL_CHECK_CERTIFICATE_REVOCATION)) { CheckCertificateRevocation = dictionary.GetBool(SessionSettings.SSL_CHECK_CERTIFICATE_REVOCATION); } // Use setting for client certificate check if one exist // otherwise enable client certificate check if a ca certificate is specified if (dictionary.Has(SessionSettings.SSL_REQUIRE_CLIENT_CERTIFICATE)) { RequireClientCertificate = dictionary.GetBool(SessionSettings.SSL_REQUIRE_CLIENT_CERTIFICATE); } // Use setting for SSL if one exist // otherwise enable ssl if certificate path is specified if (dictionary.Has(SessionSettings.SSL_ENABLE)) { UseSSL = dictionary.GetBool(SessionSettings.SSL_ENABLE); } else { UseSSL = !string.IsNullOrEmpty(CertificatePath); } if (dictionary.Has(SessionSettings.SSL_PROTOCOLS)) { var protocolString = dictionary.GetString(SessionSettings.SSL_PROTOCOLS); try { SslProtocol = (System.Security.Authentication.SslProtocols) Enum.Parse(typeof(System.Security.Authentication.SslProtocols), protocolString, true); } catch (Exception) { // TODO: figure out a way to log this somehow (even though it's not likely to occur) } } }
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); }
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); }
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); }