Example #1
0
        internal void Confirm(
            string?correlatingMessageId,
            AttributeSet set,
            TrackedAttribute tracked,
            ApplicationMessageType type, Node toOriginalSource)
        {
            switch (type)
            {
            case ApplicationMessageType.AddAttribute:
                var confirmAdd = ConfirmAttribute.From(correlatingMessageId, toOriginalSource, set, tracked, ApplicationMessageType.ConfirmAddAttribute);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, confirmAdd.ToPayload()), toOriginalSource.Collected);
                _application.InformAttributeAdded(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.RemoveAttribute:
                var confirmRemove = ConfirmAttribute.From(correlatingMessageId, toOriginalSource, set, tracked, ApplicationMessageType.ConfirmRemoveAttribute);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, confirmRemove.ToPayload()), toOriginalSource.Collected);
                _application.InformAttributeRemoved(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.ReplaceAttribute:
                var confirmReplace = ConfirmAttribute.From(correlatingMessageId, toOriginalSource, set, tracked, ApplicationMessageType.ConfirmReplaceAttribute);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, confirmReplace.ToPayload()), toOriginalSource.Collected);
                _application.InformAttributeReplaced(set.Name !, tracked.Attribute?.Name);
                break;

            default:
                throw new InvalidOperationException("Cannot confirm unknown ApplicationMessageType.");
            }
        }
 public void Confirm(Id confirmingNodeId, string attributeSetName, string attributeName, ApplicationMessageType type)
 {
     NodeId           = confirmingNodeId.Value;
     AttributeSetName = attributeSetName;
     AttributeName    = attributeName;
     Type             = type;
     ++Confirmed;
 }
Example #3
0
 public ConfirmAttribute(
     string?correlatingMessageId,
     Node node,
     AttributeSet set,
     TrackedAttribute tracked,
     ApplicationMessageType type) : base(correlatingMessageId, node, set, tracked, type)
 {
 }
        /// <summary>
        /// Returns the application message code.
        /// </summary>
        /// <param name="type">The application message type.</param>
        /// <returns></returns>
        private string ApplicationMessageCode(ApplicationMessageType type)
        {
            switch (type)
            {
            case ApplicationMessageType.MarketDataRequest:
                return("V");

                break;

            case ApplicationMessageType.MarketDataIncrementalRefresh:
                return("X");

                break;

            case ApplicationMessageType.NewOrderSingle:
                return("D");

                break;

            case ApplicationMessageType.OrderStatusRequest:
                return("H");

                break;

            case ApplicationMessageType.ExecutionReport:
                return("8");

                break;

            case ApplicationMessageType.BusinessMessageReject:
                return("j");

                break;

            case ApplicationMessageType.RequestForPosition:
                return("AN");

                break;

            case ApplicationMessageType.PositionReport:
                return("AP");

                break;

            case ApplicationMessageType.OrderCancelRequest:
                return("F");

                break;

            default:
                return("0");
            }
        }
Example #5
0
        internal void DistributeTo(
            AttributeSet set,
            TrackedAttribute tracked,
            ApplicationMessageType type,
            IEnumerable <Node> nodes)
        {
            switch (type)
            {
            case ApplicationMessageType.AddAttribute:
                var add            = AddAttribute.From(_node, set, tracked);
                var addConfirmable = _confirmables.UnconfirmedFor(add, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, add.ToPayload()), addConfirmable.UnconfirmedNodes);
                _application.InformAttributeAdded(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.RemoveAttribute:
                var remove            = RemoveAttribute.From(_node, set, tracked);
                var removeConfirmable = _confirmables.UnconfirmedFor(remove, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, remove.ToPayload()), removeConfirmable.UnconfirmedNodes);
                _application.InformAttributeRemoved(set.Name !, tracked.Attribute?.Name);
                break;

            case ApplicationMessageType.RemoveAttributeSet:
                var removeSet            = RemoveAttributeSet.From(_node, set);
                var removeSetConfirmable = _confirmables.UnconfirmedFor(removeSet, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, removeSet.ToPayload()), removeSetConfirmable.UnconfirmedNodes);
                _application.InformAttributeSetRemoved(set.Name);
                break;

            case ApplicationMessageType.ReplaceAttribute:
                var replace            = ReplaceAttribute.From(_node, set, tracked);
                var replaceConfirmable = _confirmables.UnconfirmedFor(replace, nodes);
                _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, replace.ToPayload()), replaceConfirmable.UnconfirmedNodes);
                _application.InformAttributeReplaced(set.Name !, tracked.Attribute?.Name);
                break;

            default:
                throw new InvalidOperationException("Cannot distribute unknown ApplicationMessageType.");
            }
        }
Example #6
0
 protected AttributeMessage(string?correlatingMessageId, Node node, AttributeSet set, TrackedAttribute tracked, ApplicationMessageType type)
     : base(correlatingMessageId, type, TrackingIdFor(node, type, tracked.Id))
 {
     AttributeSetName = set.Name;
     AttributeName    = tracked.Attribute?.Name;
     AttributeType    = tracked.Attribute?.Type.ToString();
     AttributeValue   = tracked.Attribute?.ToStringValue();
 }
Example #7
0
 protected AttributeMessage(Node node, AttributeSet set, TrackedAttribute tracked, ApplicationMessageType type)
     : this(NoCorrelatingMessageId, node, set, tracked, type)
 {
 }
Example #8
0
 protected ApplicationMessage(string?correlatingMessageId, ApplicationMessageType type, string trackingId)
 {
     CorrelatingMessageId = correlatingMessageId;
     TrackingId           = trackingId;
     Type = type;
 }
Example #9
0
 public static string TrackingIdFor(Node node, ApplicationMessageType type, string?trailingId) =>
 $"{node.Name.Value}:{type.ToString()}:{trailingId}";
 public void Confirm(Id confirmingNodeId, string?attributeSetName, string?attributeName, ApplicationMessageType type)
 {
     _logger.Debug($"ATTR CONFIRMATION: NODE: {confirmingNodeId.Value} SET: {attributeSetName} ATTR: {attributeName} TYPE: {type}");
 }
Example #11
0
 internal void Distribute(AttributeSet set, TrackedAttribute tracked, ApplicationMessageType type) =>
 DistributeTo(set, tracked, type, _allOtherNodes);
Example #12
0
 public static ConfirmAttribute From(
     string?correlatingMessageId,
     Node node,
     AttributeSet set,
     TrackedAttribute tracked,
     ApplicationMessageType type) => new ConfirmAttribute(correlatingMessageId, node, set, tracked, type);