in FixAntenna/NetCore/FixEngine/Session/MessageHandler/PerType/LogonMessageHandler.cs [278:346]
private bool HandleTradingSessionParameters(
FixMessage message, AcceptorFixSession acceptorFixSession,
long expectedInMsgSeqNum, long expectedOutMsgSeqNum)
{
var restoredInSeqNum = (long?) acceptorFixSession.GetAttribute(ExtendedFixSessionAttribute.SequenceWasDecremented.Name);
var currentInSeqNum = restoredInSeqNum ?? acceptorFixSession.RuntimeState.InSeqNum;
var currentOutSeqNum = acceptorFixSession.RuntimeState.OutSeqNum;
var firstSessionConnection = currentInSeqNum == 1 && currentOutSeqNum == 1;
var config = acceptorFixSession.ConfigAdapter;
var schedule = new Schedule(config.TradePeriodBegin, config.TradePeriodEnd, config.TradePeriodTimeZone);
if (schedule.IsTradingPeriodDefined())
{
if (IsLastResetOccurredAfterPeriodEnd(acceptorFixSession, schedule))
{
var reason = "Illegal state on handle of reset sequence numbers from first logon: last reset is after scheduled end of trading period";
OnFailedSeqNumResetFromFirstLogon(message, acceptorFixSession, reason, null);
}
else if (!IsLastResetOccurredInTradingPeriod(acceptorFixSession, schedule) || firstSessionConnection)
{
if (Log.IsTraceEnabled)
{
Log.Trace("Trade period is defined for session " + Session.Parameters.SessionId +
" and needs sequence reset (first connect in this period)");
}
return ResetSequencesFromFirstLogon(message, acceptorFixSession, expectedInMsgSeqNum, expectedOutMsgSeqNum);
}
else
{
if (Log.IsTraceEnabled)
{
Log.Trace("No needs reset for session " + Session.Parameters.SessionId +
" in this trading period (it was done already)");
}
}
}
else if (schedule.IsOnlyPeriodBeginDefined())
{
if (!IsLastResetOccurredAfterPeriodBegin(acceptorFixSession, schedule) || firstSessionConnection)
{
if (Log.IsTraceEnabled)
{
Log.Trace("Trade period begins for session " + Session.Parameters.SessionId +
" and needs sequence reset (first connect in this period)");
}
return ResetSequencesFromFirstLogon(message, acceptorFixSession, expectedInMsgSeqNum, expectedOutMsgSeqNum);
}
else
{
if (Log.IsTraceEnabled)
{
Log.Trace("Trade period begins for session " + Session.Parameters.SessionId +
" but reset was done before");
}
}
}
else
{
var reason = "Trading period is not defined for the session with enabled reset sequence from first logon. Session: "
+ acceptorFixSession.Parameters.SessionId;
Log.Warn(reason);
return true;
}
return false;
}