Ejemplo n.º 1
0
        public void ReverseRoute(Header header)
        {
            // required routing tags
            this.Header.RemoveField(Tags.BeginString);
            this.Header.RemoveField(Tags.SenderCompID);
            this.Header.RemoveField(Tags.SenderSubID);
            this.Header.RemoveField(Tags.SenderLocationID);
            this.Header.RemoveField(Tags.TargetCompID);
            this.Header.RemoveField(Tags.TargetSubID);
            this.Header.RemoveField(Tags.TargetLocationID);

            if (header.IsSetField(Tags.BeginString))
            {
                string beginString = header.GetField(Tags.BeginString);
                if (beginString.Length > 0)
                    this.Header.SetField(new BeginString(beginString));

                this.Header.RemoveField(Tags.OnBehalfOfLocationID);
                this.Header.RemoveField(Tags.DeliverToLocationID);

                if (beginString.CompareTo("FIX.4.1") >= 0)
                {
                    if (header.IsSetField(Tags.OnBehalfOfLocationID))
                    {
                        string onBehalfOfLocationID = header.GetField(Tags.OnBehalfOfLocationID);
                        if (onBehalfOfLocationID.Length > 0)
                            this.Header.SetField(new DeliverToLocationID(onBehalfOfLocationID));
                    }

                    if (header.IsSetField(Tags.DeliverToLocationID))
                    {
                        string deliverToLocationID = header.GetField(Tags.DeliverToLocationID);
                        if (deliverToLocationID.Length > 0)
                            this.Header.SetField(new OnBehalfOfLocationID(deliverToLocationID));
                    }
                }
            }

            if (header.IsSetField(Tags.SenderCompID))
            {
                SenderCompID senderCompID = new SenderCompID();
                header.GetField(senderCompID);
                if (senderCompID.Obj.Length > 0)
                    this.Header.SetField(new TargetCompID(senderCompID.Obj));
            }

            if (header.IsSetField(Tags.SenderSubID))
            {
                SenderSubID senderSubID = new SenderSubID();
                header.GetField(senderSubID);
                if (senderSubID.Obj.Length > 0)
                    this.Header.SetField(new TargetSubID(senderSubID.Obj));
            }

            if (header.IsSetField(Tags.SenderLocationID))
            {
                SenderLocationID senderLocationID = new SenderLocationID();
                header.GetField(senderLocationID);
                if (senderLocationID.Obj.Length > 0)
                    this.Header.SetField(new TargetLocationID(senderLocationID.Obj));
            }

            if (header.IsSetField(Tags.TargetCompID))
            {
                TargetCompID targetCompID = new TargetCompID();
                header.GetField(targetCompID);
                if (targetCompID.Obj.Length > 0)
                    this.Header.SetField(new SenderCompID(targetCompID.Obj));
            }

            if (header.IsSetField(Tags.TargetSubID))
            {
                TargetSubID targetSubID = new TargetSubID();
                header.GetField(targetSubID);
                if (targetSubID.Obj.Length > 0)
                    this.Header.SetField(new SenderSubID(targetSubID.Obj));
            }

            if (header.IsSetField(Tags.TargetLocationID))
            {
                TargetLocationID targetLocationID = new TargetLocationID();
                header.GetField(targetLocationID);
                if (targetLocationID.Obj.Length > 0)
                    this.Header.SetField(new SenderLocationID(targetLocationID.Obj));
            }

            // optional routing tags
            this.Header.RemoveField(Tags.OnBehalfOfCompID);
            this.Header.RemoveField(Tags.OnBehalfOfSubID);
            this.Header.RemoveField(Tags.DeliverToCompID);
            this.Header.RemoveField(Tags.DeliverToSubID);

            if(header.IsSetField(Tags.OnBehalfOfCompID))
            {
                string onBehalfOfCompID = header.GetField(Tags.OnBehalfOfCompID);
                if(onBehalfOfCompID.Length > 0)
                    this.Header.SetField(new DeliverToCompID(onBehalfOfCompID));
            }

            if(header.IsSetField(Tags.OnBehalfOfSubID))
            {
                string onBehalfOfSubID = header.GetField(  Tags.OnBehalfOfSubID);
                if(onBehalfOfSubID.Length > 0)
                    this.Header.SetField(new DeliverToSubID(onBehalfOfSubID));
            }

            if(header.IsSetField(Tags.DeliverToCompID))
            {
                string deliverToCompID = header.GetField(Tags.DeliverToCompID);
                if(deliverToCompID.Length > 0)
                    this.Header.SetField(new OnBehalfOfCompID(deliverToCompID));
            }

            if(header.IsSetField(Tags.DeliverToSubID))
            {
                string deliverToSubID = header.GetField(Tags.DeliverToSubID);
                if(deliverToSubID.Length > 0)
                    this.Header.SetField(new OnBehalfOfSubID(deliverToSubID));
            }
        }
Ejemplo n.º 2
0
        public void ReverseRoute(Header header)
        {
            // required routing tags
            this.Header.RemoveField(Tags.BeginString);
            this.Header.RemoveField(Tags.SenderCompID);
            this.Header.RemoveField(Tags.SenderSubID);
            this.Header.RemoveField(Tags.SenderLocationID);
            this.Header.RemoveField(Tags.TargetCompID);
            this.Header.RemoveField(Tags.TargetSubID);
            this.Header.RemoveField(Tags.TargetLocationID);

            if (header.IsSetField(Tags.BeginString))
            {
                string beginString = header.GetField(Tags.BeginString);
                if (beginString.Length > 0)
                {
                    this.Header.SetField(new BeginString(beginString));
                }

                this.Header.RemoveField(Tags.OnBehalfOfLocationID);
                this.Header.RemoveField(Tags.DeliverToLocationID);

                if (beginString.CompareTo("FIX.4.1") >= 0)
                {
                    if (header.IsSetField(Tags.OnBehalfOfLocationID))
                    {
                        string onBehalfOfLocationID = header.GetField(Tags.OnBehalfOfLocationID);
                        if (onBehalfOfLocationID.Length > 0)
                        {
                            this.Header.SetField(new DeliverToLocationID(onBehalfOfLocationID));
                        }
                    }

                    if (header.IsSetField(Tags.DeliverToLocationID))
                    {
                        string deliverToLocationID = header.GetField(Tags.DeliverToLocationID);
                        if (deliverToLocationID.Length > 0)
                        {
                            this.Header.SetField(new OnBehalfOfLocationID(deliverToLocationID));
                        }
                    }
                }
            }

            if (header.IsSetField(Tags.SenderCompID))
            {
                SenderCompID senderCompID = new SenderCompID();
                header.GetField(senderCompID);
                if (senderCompID.Obj.Length > 0)
                {
                    this.Header.SetField(new TargetCompID(senderCompID.Obj));
                }
            }

            if (header.IsSetField(Tags.SenderSubID))
            {
                SenderSubID senderSubID = new SenderSubID();
                header.GetField(senderSubID);
                if (senderSubID.Obj.Length > 0)
                {
                    this.Header.SetField(new TargetSubID(senderSubID.Obj));
                }
            }

            if (header.IsSetField(Tags.SenderLocationID))
            {
                SenderLocationID senderLocationID = new SenderLocationID();
                header.GetField(senderLocationID);
                if (senderLocationID.Obj.Length > 0)
                {
                    this.Header.SetField(new TargetLocationID(senderLocationID.Obj));
                }
            }

            if (header.IsSetField(Tags.TargetCompID))
            {
                TargetCompID targetCompID = new TargetCompID();
                header.GetField(targetCompID);
                if (targetCompID.Obj.Length > 0)
                {
                    this.Header.SetField(new SenderCompID(targetCompID.Obj));
                }
            }

            if (header.IsSetField(Tags.TargetSubID))
            {
                TargetSubID targetSubID = new TargetSubID();
                header.GetField(targetSubID);
                if (targetSubID.Obj.Length > 0)
                {
                    this.Header.SetField(new SenderSubID(targetSubID.Obj));
                }
            }

            if (header.IsSetField(Tags.TargetLocationID))
            {
                TargetLocationID targetLocationID = new TargetLocationID();
                header.GetField(targetLocationID);
                if (targetLocationID.Obj.Length > 0)
                {
                    this.Header.SetField(new SenderLocationID(targetLocationID.Obj));
                }
            }

            // optional routing tags
            this.Header.RemoveField(Tags.OnBehalfOfCompID);
            this.Header.RemoveField(Tags.OnBehalfOfSubID);
            this.Header.RemoveField(Tags.DeliverToCompID);
            this.Header.RemoveField(Tags.DeliverToSubID);

            if (header.IsSetField(Tags.OnBehalfOfCompID))
            {
                string onBehalfOfCompID = header.GetField(Tags.OnBehalfOfCompID);
                if (onBehalfOfCompID.Length > 0)
                {
                    this.Header.SetField(new DeliverToCompID(onBehalfOfCompID));
                }
            }

            if (header.IsSetField(Tags.OnBehalfOfSubID))
            {
                string onBehalfOfSubID = header.GetField(Tags.OnBehalfOfSubID);
                if (onBehalfOfSubID.Length > 0)
                {
                    this.Header.SetField(new DeliverToSubID(onBehalfOfSubID));
                }
            }

            // A.Chisholm 19-01-2017
            // As we're a hub we want to reject from ourselves and not OBO the inbound DeliverToCompID
            //if(header.IsSetField(Tags.DeliverToCompID))
            //{
            //    string deliverToCompID = header.GetField(Tags.DeliverToCompID);
            //    if(deliverToCompID.Length > 0)
            //        this.Header.SetField(new OnBehalfOfCompID(deliverToCompID));
            //}

            if (header.IsSetField(Tags.DeliverToSubID))
            {
                string deliverToSubID = header.GetField(Tags.DeliverToSubID);
                if (deliverToSubID.Length > 0)
                {
                    this.Header.SetField(new OnBehalfOfSubID(deliverToSubID));
                }
            }
        }
Ejemplo n.º 3
0
        public void ReverseRoute(Header header)
        {
            // required routing tags
            this.Header.RemoveField(Tags.BeginString);
            this.Header.RemoveField(Tags.SenderCompID);
            this.Header.RemoveField(Tags.SenderSubID);
            this.Header.RemoveField(Tags.SenderLocationID);
            this.Header.RemoveField(Tags.TargetCompID);
            this.Header.RemoveField(Tags.TargetSubID);
            this.Header.RemoveField(Tags.TargetLocationID);

            if (header.IsSetField(Tags.BeginString))
            {
                string beginString = header.GetField(Tags.BeginString);
                if (beginString.Length > 0)
                {
                    this.Header.SetField(new BeginString(beginString));
                }

                this.Header.RemoveField(Tags.OnBehalfOfLocationID);
                this.Header.RemoveField(Tags.DeliverToLocationID);

                if (beginString.CompareTo("FIX.4.1") >= 0)
                {
                    if (header.IsSetField(Tags.OnBehalfOfLocationID))
                    {
                        string onBehalfOfLocationID = header.GetField(Tags.OnBehalfOfLocationID);
                        if (onBehalfOfLocationID.Length > 0)
                        {
                            this.Header.SetField(new DeliverToLocationID(onBehalfOfLocationID));
                        }
                    }

                    if (header.IsSetField(Tags.DeliverToLocationID))
                    {
                        string deliverToLocationID = header.GetField(Tags.DeliverToLocationID);
                        if (deliverToLocationID.Length > 0)
                        {
                            this.Header.SetField(new OnBehalfOfLocationID(deliverToLocationID));
                        }
                    }
                }
            }

            if (header.IsSetField(Tags.SenderCompID))
            {
                SenderCompID senderCompID = new SenderCompID();
                header.GetField(senderCompID);
                if (senderCompID.Obj.Length > 0)
                {
                    this.Header.SetField(new TargetCompID(senderCompID.Obj));
                }
            }

            if (header.IsSetField(Tags.SenderSubID))
            {
                SenderSubID senderSubID = new SenderSubID();
                header.GetField(senderSubID);
                if (senderSubID.Obj.Length > 0)
                {
                    this.Header.SetField(new TargetSubID(senderSubID.Obj));
                }
            }

            if (header.IsSetField(Tags.SenderLocationID))
            {
                SenderLocationID senderLocationID = new SenderLocationID();
                header.GetField(senderLocationID);
                if (senderLocationID.Obj.Length > 0)
                {
                    this.Header.SetField(new TargetLocationID(senderLocationID.Obj));
                }
            }

            if (header.IsSetField(Tags.TargetCompID))
            {
                TargetCompID targetCompID = new TargetCompID();
                header.GetField(targetCompID);
                if (targetCompID.Obj.Length > 0)
                {
                    this.Header.SetField(new SenderCompID(targetCompID.Obj));
                }
            }

            if (header.IsSetField(Tags.TargetSubID))
            {
                TargetSubID targetSubID = new TargetSubID();
                header.GetField(targetSubID);
                if (targetSubID.Obj.Length > 0)
                {
                    this.Header.SetField(new SenderSubID(targetSubID.Obj));
                }
            }

            if (header.IsSetField(Tags.TargetLocationID))
            {
                TargetLocationID targetLocationID = new TargetLocationID();
                header.GetField(targetLocationID);
                if (targetLocationID.Obj.Length > 0)
                {
                    this.Header.SetField(new SenderLocationID(targetLocationID.Obj));
                }
            }

            // optional routing tags
            this.Header.RemoveField(Tags.OnBehalfOfCompID);
            this.Header.RemoveField(Tags.OnBehalfOfSubID);
            this.Header.RemoveField(Tags.DeliverToCompID);
            this.Header.RemoveField(Tags.DeliverToSubID);

            if (header.IsSetField(Tags.OnBehalfOfCompID))
            {
                string onBehalfOfCompID = header.GetField(Tags.OnBehalfOfCompID);
                if (onBehalfOfCompID.Length > 0)
                {
                    this.Header.SetField(new DeliverToCompID(onBehalfOfCompID));
                }
            }

            if (header.IsSetField(Tags.OnBehalfOfSubID))
            {
                string onBehalfOfSubID = header.GetField(Tags.OnBehalfOfSubID);
                if (onBehalfOfSubID.Length > 0)
                {
                    this.Header.SetField(new DeliverToSubID(onBehalfOfSubID));
                }
            }

            if (header.IsSetField(Tags.DeliverToCompID))
            {
                string deliverToCompID = header.GetField(Tags.DeliverToCompID);
                if (deliverToCompID.Length > 0)
                {
                    this.Header.SetField(new OnBehalfOfCompID(deliverToCompID));
                }
            }

            if (header.IsSetField(Tags.DeliverToSubID))
            {
                string deliverToSubID = header.GetField(Tags.DeliverToSubID);
                if (deliverToSubID.Length > 0)
                {
                    this.Header.SetField(new OnBehalfOfSubID(deliverToSubID));
                }
            }
        }
Ejemplo n.º 4
0
        public void Next(Message message)
        {
            Header header  = message.Header;
            string msgType = "";

            try
            {
                msgType = header.GetField(Fields.Tags.MsgType);
                string beginString = header.GetField(Fields.Tags.BeginString);

                if (!beginString.Equals(this.SessionID.BeginString))
                {
                    throw new UnsupportedVersion();
                }

                if (this.SessionID.IsFIXT && !Message.IsAdminMsgType(msgType))
                {
                    throw new UnsupportedVersion("'FIXT' Sessions are not implemented yet!");
                }
                else
                {
                    this.SessionDataDictionary.Validate(message, beginString, msgType);
                }

                if (MsgType.LOGON.Equals(msgType))
                {
                    NextLogon(message);
                }
                else if (MsgType.HEARTBEAT.Equals(msgType))
                {
                    NextHeartbeat(message);
                }
                else if (MsgType.TEST_REQUEST.Equals(msgType))
                {
                    NextTestRequest(message);
                }
                else if (MsgType.SEQUENCE_RESET.Equals(msgType))
                {
                    NextSequenceReset(message);
                }
                else if (MsgType.LOGOUT.Equals(msgType))
                {
                    NextLogout(message);
                }
                else if (MsgType.RESEND_REQUEST.Equals(msgType))
                {
                    NextResendRequest(message);
                }
                else
                {
                    if (!Verify(message))
                    {
                        return;
                    }
                    state_.IncrNextTargetMsgSeqNum();
                }
            }
            catch (TagException e)
            {
                if (null != e.InnerException)
                {
                    this.Log.OnEvent(e.InnerException.Message);
                }
                GenerateReject(message, e.sessionRejectReason, e.field);
            }
            catch (UnsupportedVersion)
            {
                if (MsgType.LOGOUT.Equals(msgType))
                {
                    NextLogout(message);
                }
                else
                {
                    GenerateLogout("Incorrect BeginString");
                    state_.IncrNextTargetMsgSeqNum();
                }
            }
            catch (UnsupportedMessageType e)
            {
                this.Log.OnEvent("Unsupported message type: " + e.Message);
                GenerateBusinessMessageReject(message, Fields.BusinessRejectReason.UNKNOWN_MESSAGE_TYPE, 0);
            }
            NextQueued();
        }