public IEnumerable <Subscription> GetSubscriptions(ISubscriptionIdMessage message) { var time = message is IServerTimeMessage timeMsg ? timeMsg.ServerTime : (DateTimeOffset?)null; var processed = new HashSet <SubscriptionInfo>(); foreach (var id in message.GetSubscriptionIds()) { var info = TryGetSubscription(id, false, false, time); if (info == null) { continue; } if (!processed.Add(info)) { continue; } if (info.Parent == null) { yield return(info.Subscription); } else { if (!processed.Add(info.Parent)) { continue; } yield return(info.Parent.Subscription); } } }
public IEnumerable <Subscription> ProcessLookupResponse <T>(ISubscriptionIdMessage message, T[] items) { var subscriptions = new List <Subscription>(); foreach (var id in message.GetSubscriptionIds()) { var info = TryGetInfo(id, true, false, null, true); if (info == null || info.HasResult) { continue; } if (info.LookupItems == null) { _connector.AddWarningLog(LocalizedStrings.Str2142Params, info.Subscription.SubscriptionMessage); continue; } info.LookupItems.AddRange(items.Cast <object>()); subscriptions.Add(info.Subscription); } return(subscriptions); }
private void TrySendToEmulator(ISubscriptionIdMessage message) { foreach (var id in message.GetSubscriptionIds()) { if (_subscriptionIds.Contains(id)) { SendToEmulator((Message)message); break; } } }
public IEnumerable <Subscription> GetSubscriptions(ISubscriptionIdMessage message) { var time = message is IServerTimeMessage timeMsg ? timeMsg.ServerTime : (DateTimeOffset?)null; foreach (var id in message.GetSubscriptionIds()) { var subscription = TryGetSubscription(id, true, false, time); if (subscription != null) { yield return(subscription); } } }
private bool CanStore(ISubscriptionIdMessage message) { if (!Enabled) { return(false); } if (!FilterSubscription) { return(true); } return(message.GetSubscriptionIds().Any(_subscriptionsById.Contains)); }
private void ApplySubscriptionIds(ISubscriptionIdMessage message, ChildSubscription child) { var ids = message.GetSubscriptionIds(); var initialId = child.Parent.Origin.TransactionId; var newIds = child.Subscribers.CachedKeys.Concat(child.Parent.Alls.CachedKeys); if (ids.Length == 1 && ids[0] == initialId) { message.SetSubscriptionIds(newIds); } else { message.SetSubscriptionIds(ids.Where(id => id != initialId).Concat(newIds).ToArray()); } }
private bool RaiseReceived <TEntity>(TEntity entity, ISubscriptionIdMessage message, Action <Subscription, TEntity> evt) { var anyOnline = false; foreach (var subscription in _subscriptionManager.GetSubscriptions(message)) { if (!anyOnline && subscription.State == SubscriptionStates.Online) { anyOnline = true; } evt?.Invoke(subscription, entity); } return(anyOnline); }
private void RaiseReceived <TEntity>(TEntity entity, ISubscriptionIdMessage message, Action <Subscription, TEntity> evt) { if (evt == null) { return; } foreach (var id in message.GetSubscriptionIds()) { if (!_subscriptions.TryGetValue(id, out var subscription)) { continue; } evt(subscription, entity); } }
private void RaiseReceived <TEntity>(TEntity entity, ISubscriptionIdMessage message, Action <Subscription, TEntity> evt) { if (evt == null) { return; } foreach (var id in message.GetSubscriptionIds()) { var subscription = TryGetSubscription(id); if (subscription != null) { evt(subscription, entity); } } }
private void ApplyTransactionalSubscriptionIds <TMessage>(ISubscriptionIdMessage message, Dictionary <long, SubscriptionInfo <TMessage> > lookupSubscribers) where TMessage : Message, ISubscriptionIdMessage { lock (_sync) { if (message.OriginalTransactionId > 0 && lookupSubscribers.ContainsKey(message.OriginalTransactionId)) { message.SubscriptionId = message.OriginalTransactionId; } if (_pfLookupSubscribers.Count == 0) { return; } message.SubscriptionIds = lookupSubscribers.First().Value.Subscribers.Cache; } }
private void RaiseReceived <TEntity>(TEntity entity, ISubscriptionIdMessage message, Action <Subscription, TEntity> evt) { if (evt == null) { return; } var time = message is IServerTimeMessage timeMsg ? timeMsg.ServerTime : (DateTimeOffset?)null; foreach (var id in message.GetSubscriptionIds()) { var subscription = _subscriptionManager.TryGetSubscription(id, false, time); if (subscription != null) { evt(subscription, entity); } } }
public void ProcessLookupResponse(ISubscriptionIdMessage message, object item) { foreach (var id in message.GetSubscriptionIds()) { var info = TryGetInfo(id, false); if (info == null) { continue; } if (info.Lookup == null) { _connector.AddWarningLog(LocalizedStrings.Str2142Params, info.Subscription.SubscriptionMessage); continue; } info.Lookup.Items.Add(item); } }
public void ProcessLookupResponse <T>(ISubscriptionIdMessage message, T[] items) { foreach (var id in message.GetSubscriptionIds()) { var info = TryGetInfo(id, false); if (info == null || info.HasResult) { continue; } if (info.LookupItems == null) { _connector.AddWarningLog(LocalizedStrings.Str2142Params, info.Subscription.SubscriptionMessage); continue; } info.LookupItems.AddRange(items.Cast <object>()); } }
private void ApplySubscriptionIds(ISubscriptionIdMessage subscrMsg, ParentSubscription parent, long[] newIds) { var ids = subscrMsg.GetSubscriptionIds(); var initialId = parent.Origin.TransactionId; newIds = newIds.Concat(parent.Alls.CachedKeys); if (subscrMsg is ISecurityIdMessage secIdMsg && parent.NonAlls.TryGetValue(secIdMsg.SecurityId, out var set)) { newIds = newIds.Concat(set.Cache); } if (ids.Length == 1 && ids[0] == initialId) { subscrMsg.SetSubscriptionIds(newIds); } else { subscrMsg.SetSubscriptionIds(ids.Where(id => id != initialId).Concat(newIds).ToArray()); } }
private bool?RaiseReceived <TEntity>(TEntity entity, ISubscriptionIdMessage message, Action <Subscription, TEntity> evt) { return(RaiseReceived(entity, message, evt, out _)); }
private void ApplySubscriptionIds(ISubscriptionIdMessage subscrMsg, ChildSubscription child) { ApplySubscriptionIds(subscrMsg, child.Parent, child.Subscribers.CachedKeys); }
public IEnumerable <Subscription> ProcessLookupResponse <T>(ISubscriptionIdMessage message, T item) { return(ProcessLookupResponse(message, new[] { item })); }
public void ProcessLookupResponse <T>(ISubscriptionIdMessage message, T item) { ProcessLookupResponse(message, new[] { item }); }
private bool?RaiseReceived <TEntity>(TEntity entity, ISubscriptionIdMessage message, Action <Subscription, TEntity> evt, out bool?anyCanOnline) { return(RaiseReceived(entity, _subscriptionManager.GetSubscriptions(message), evt, out anyCanOnline)); }
private void ApplySubscriptionIds(ISubscriptionIdMessage message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } long originTransId; switch (message) { case CandleMessage candleMsg: originTransId = candleMsg.OriginalTransactionId; break; case ExecutionMessage execMsg: switch (execMsg.ExecutionType) { case ExecutionTypes.Tick: case ExecutionTypes.OrderLog: originTransId = execMsg.OriginalTransactionId; break; default: ApplyTransactionalSubscriptionIds(execMsg, _orderStatusSubscribers); return; } break; case NewsMessage newsMsg: originTransId = newsMsg.OriginalTransactionId; break; case BoardMessage boardStateMsg: originTransId = boardStateMsg.OriginalTransactionId; break; case BoardStateMessage boardStateMsg: originTransId = boardStateMsg.OriginalTransactionId; break; case PortfolioMessage _: case BasePositionChangeMessage _: ApplyTransactionalSubscriptionIds(message, _pfLookupSubscribers); return; default: throw new ArgumentOutOfRangeException(nameof(message), message.ToString()); } lock (_sync) { if (!_mdSubscribersById.TryGetValue(originTransId, out var info)) { return; } //if (info.Message.TransactionId == originTransId && info.Subscribers.Count > 1) message.SubscriptionIds = info.Subscribers.Cache; } }