protected virtual SessionsRuntimeInformationMessage Receive(RequestSymbolsRuntimeInformationMessage message) { DataSourceStub.IImplementation implementation = Implementation; List <RuntimeDataSessionInformation> result = new List <RuntimeDataSessionInformation>(); if (implementation != null && OperationalState == OperationalStateEnum.Operational) { foreach (Symbol symbol in message.Symbols) { lock (this) { if (_symbolsRunningSessions.ContainsKey(symbol) && _symbolsRunningSessions[symbol] != null) { result.Add(_symbolsRunningSessions[symbol].SessionInformation); continue; } } // Failed to find in already existing, query the implementation to create us a new one. RuntimeDataSessionInformation sessionInformation = implementation.GetSymbolSessionRuntimeInformation(symbol); if (sessionInformation != null) { lock (this) { _symbolsRunningSessions[sessionInformation.Info.Symbol] = new CombinedDataSubscriptionInformation(sessionInformation); } result.Add(sessionInformation); } } } return(new SessionsRuntimeInformationMessage(result, implementation != null && OperationalState == OperationalStateEnum.Operational)); }
public bool Initialize(DataSourceStub.IImplementation implementation) { _implementation = implementation; StatusSynchronizationSource = implementation; return(true); }
void SendQuoteUpdate(TransportInfo[] receivers, DataSessionInfo session) { DataSourceStub.IImplementation implementation = Implementation; if (implementation == null) { return; } QuoteUpdateMessage message = new QuoteUpdateMessage(session, implementation.GetQuoteUpdate(session), true); SendRespondingToMany(receivers, message); }
void SendDataHistoryUpdate(TransportInfo[] receivers, DataSessionInfo session, DataHistoryRequest request) { DataSourceStub.IImplementation implementation = Implementation; if (implementation == null) { return; } DataHistoryUpdate responce = implementation.GetDataHistoryUpdate(session, request); SendRespondingToMany(receivers, new DataHistoryUpdateMessage(session, responce, responce != null)); }
protected virtual RequestSymbolsResponceMessage Receive(RequestSymbolsMessage message) { RequestSymbolsResponceMessage responce = new RequestSymbolsResponceMessage(true); DataSourceStub.IImplementation implementation = Implementation; if (implementation != null && OperationalState == OperationalStateEnum.Operational) {// Synchronous. responce.SymbolsPeriods = implementation.SearchSymbols(message.SymbolMatch, message.ResultLimit); } else { responce.OperationResult = false; } return(responce); }
public CombinedDataSubscriptionInformation GetUnsafeSessionSubscriptions(DataSessionInfo session) { DataSourceStub.IImplementation implementation = Implementation; if (implementation == null) { return(null); } bool isSymbolRunningSession; lock (this) { isSymbolRunningSession = (_symbolsRunningSessions.ContainsKey(session.Symbol) == false); } if (isSymbolRunningSession) { SystemMonitor.OperationWarning("Received a request for unknow session, creating a new session."); // Make sure to leave the sessionInformation orderInfo request outside of locks. RuntimeDataSessionInformation sessionInformation = implementation.GetSymbolSessionRuntimeInformation(session.Symbol); lock (this) { _symbolsRunningSessions.Add(sessionInformation.Info.Symbol, new CombinedDataSubscriptionInformation(sessionInformation)); } } lock (this) { //if (_sessionsSubscriptions.ContainsKey(session) == false) //{ // _sessionsSubscriptions[session] = new CombinedDataSubscriptionInformation(session); //} return(_symbolsRunningSessions[session.Symbol]); } }
protected virtual DataSubscriptionResponceMessage Receive(DataSubscriptionRequestMessage message) { if (message.TransportInfo.OriginalSenderId.HasValue == false) { SystemMonitor.Error("Received a message with no original sender. Dropped."); return(null); } DataSourceStub.IImplementation implementation = Implementation; if (message.SessionInfo.IsEmtpy) {// General (un)subscription requestMessage, not specific to a sessionInformation. if (message.Subscribe) { SystemMonitor.OperationError("Unexpected combination of empty session and subscribe request, ignored."); } else {// Unsubscribe to each that has a orderInfo for this original sender. lock (this) { foreach (CombinedDataSubscriptionInformation combined in _symbolsRunningSessions.Values) { if (combined.FullUnsubscribe(message.TransportInfo.OriginalSenderId.Value)) {// For every sessionInformation that has something // Make sure to pass combined as parameter, otherwise the value is in foreach and chages before the thread starts. GeneralHelper.FireAndForget( delegate(CombinedDataSubscriptionInformation combinedValue) { if (implementation != null) {// First allow the implementation to unsubscribe since it needs the combined dataDelivery. implementation.SessionDataSubscriptionUpdate(combinedValue.SessionInformation.Info, message.Subscribe, message.Information); } }, combined); } } } } } else { if (_symbolsRunningSessions.ContainsKey(message.SessionInfo.Symbol) == false || _symbolsRunningSessions[message.SessionInfo.Symbol].SessionInformation.Info.Equals(message.SessionInfo) == false) { SystemMonitor.Warning("Subsribe request for non existing session."); return(new DataSubscriptionResponceMessage(message.SessionInfo, false)); } CombinedDataSubscriptionInformation combined = GetUnsafeSessionSubscriptions(message.SessionInfo); if (combined != null) { combined.HandleRequest(message.TransportInfo, message.Subscribe, message.Information); if (implementation != null) { GeneralHelper.FireAndForget(delegate() { implementation.SessionDataSubscriptionUpdate(message.SessionInfo, message.Subscribe, message.Information); }); } } else { SystemMonitor.OperationError("Combined subscription info not found."); } } // Finalizing / responding section. if (message.RequestResponce) { return(new DataSubscriptionResponceMessage(message.SessionInfo, true)); } return(null); }
/// <summary> /// /// </summary> public bool Initialize(DataSourceStub.IImplementation implementation) { _implementation = implementation; StatusSynchronizationSource = implementation; return true; }