Ejemplo n.º 1
0
        protected void DoTargetTooHigh(Message msg, int msgSeqNum)
        {
            string beginString = msg.Header.GetField(Fields.Tags.BeginString);

            this.Log.OnEvent("MsgSeqNum too high, expecting " + state_.GetNextTargetMsgSeqNum() + " but received " + msgSeqNum);
            state_.Queue(msgSeqNum, msg);

            if (state_.ResendRequested())
            {
                ResendRange range = state_.GetResendRange();

                if (!this.SendRedundantResendRequests && msgSeqNum >= range.BeginSeqNo)
                {
                    this.Log.OnEvent("Already sent ResendRequest FROM: " + range.BeginSeqNo + " TO: " + range.EndSeqNo + ".  Not sending another.");
                    return;
                }
            }

            GenerateResendRequest(beginString, msgSeqNum);
        }
Ejemplo n.º 2
0
        public bool Verify(Message msg, bool checkTooHigh, bool checkTooLow)
        {
            int    msgSeqNum = 0;
            string msgType   = "";

            try
            {
                msgType = msg.Header.GetField(Fields.Tags.MsgType);
                string senderCompID = msg.Header.GetField(Fields.Tags.SenderCompID);
                string targetCompID = msg.Header.GetField(Fields.Tags.TargetCompID);

                if (!IsCorrectCompID(senderCompID, targetCompID))
                {
                    GenerateReject(msg, FixValues.SessionRejectReason.COMPID_PROBLEM);
                    GenerateLogout();
                    return(false);
                }

                if (checkTooHigh || checkTooLow)
                {
                    msgSeqNum = msg.Header.GetInt(Fields.Tags.MsgSeqNum);
                }

                if (checkTooHigh && IsTargetTooHigh(msgSeqNum))
                {
                    DoTargetTooHigh(msg, msgSeqNum);
                    return(false);
                }
                else if (checkTooLow && IsTargetTooLow(msgSeqNum))
                {
                    DoTargetTooLow(msg, msgSeqNum);
                    return(false);
                }

                if ((checkTooHigh || checkTooLow) && state_.ResendRequested())
                {
                    ResendRange range = state_.GetResendRange();
                    if (msgSeqNum >= range.EndSeqNo)
                    {
                        this.Log.OnEvent("ResendRequest for messages FROM: " + range.BeginSeqNo + " TO: " + range.EndSeqNo + " has been satisfied.");
                        state_.SetResendRange(0, 0);
                    }
                }

                if (CheckLatency && !IsGoodTime(msg))
                {
                    this.Log.OnEvent("Sending time accuracy problem");
                    GenerateReject(msg, FixValues.SessionRejectReason.SENDING_TIME_ACCURACY_PROBLEM);
                    GenerateLogout();
                    return(false);
                }
            }
            catch (System.Exception e)
            {
                this.Log.OnEvent("Verify failed: " + e.Message);
                Disconnect("Verify failed: " + e.Message);
                return(false);
            }

            state_.LastReceivedTimeTickCount = System.Environment.TickCount;
            state_.TestRequestCounter        = 0;

            if (Message.IsAdminMsgType(msgType))
            {
                this.Application.FromAdmin(msg, this.SessionID);
            }
            else
            {
                this.Application.FromApp(msg, this.SessionID);
            }

            return(true);
        }