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));
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        bool DoAddEntry(DataStoreEntry entry)
        {
            entry.Initialize(_dataStoreFilesFolder);

            lock (_entriesAndSessions)
            {
                if (_entriesAndSessions.ContainsKey(entry))
                {
                    SystemMonitor.OperationWarning("Entry already added.");
                    return(false);
                }

                if (entry.Symbol.IsEmpty)
                {
                    SystemMonitor.Warning("Entry added before initialized.");
                    return(false);
                }

                // The sessionInformation reuses the entry Guid, so that it can be easily persisted further.
                DataSessionInfo entrySessionInfo = new DataSessionInfo(entry.Guid, "Data Store Session [" + entry.Symbol.Name + "]",
                                                                       entry.Symbol, DefaultSessionLotSize, entry.DecimalDigits);

                RuntimeDataSessionInformation session = new RuntimeDataSessionInformation(entrySessionInfo, entry.Period.Value);
                _entriesAndSessions.Add(entry, session);
            }

            return(true);
        }
        public bool InitializeIntegrationSession(string symbol,
                                                 decimal modePoint, decimal modeDigits, decimal modeSpread, decimal modeStopLevel, decimal modeLotSize, decimal modeTickValue,
                                                 decimal modeTickSize, decimal modeSwapLong, decimal modeSwapShort, decimal modeStarting, decimal modeExpiration,
                                                 decimal modeTradeAllowed, decimal modeMinLot, decimal modeLotStep, decimal modeMaxLot, decimal modeSwapType,
                                                 decimal modeProfitCalcMode, decimal modeMarginCalcMode, decimal modeMarginInit, decimal modeMarginMaintenance,
                                                 decimal modeMarginHedged, decimal modeMarginRequired, decimal modeFreezeLevel)
        {
            TracerHelper.Trace(symbol);
            CombinedDataSubscriptionInformation session = GetDataSession(symbol);

            if (session == null)
            {
                DataSessionInfo sessionInfo = new DataSessionInfo(Guid.NewGuid(), symbol,
                                                                  CreateSymbol(symbol), modeLotSize, (int)modeDigits);

                RuntimeDataSessionInformation runtimeSession = new RuntimeDataSessionInformation(sessionInfo);

                session = new CombinedDataSubscriptionInformation(runtimeSession);

                lock (this)
                {
                    _dataSessions.Add(sessionInfo.Symbol, session);
                }
            }

            return(true);
        }
Example #4
0
        public bool AddSymbol(ComponentId dataSourceId, Symbol symbol, out string operationResultMessage)
        {
            if (_dataSourceId.HasValue && _dataSourceId.Value != dataSourceId)
            {
                operationResultMessage = "One source per watch component currently supported.";
                SystemMonitor.Error(operationResultMessage);
                return(false);
            }

            _dataSourceId = dataSourceId;
            if (_delivery == null)
            {
                _delivery = base.ObtainDataDelivery(_dataSourceId.Value);
            }

            RuntimeDataSessionInformation info = _delivery.GetSymbolRuntimeSessionInformation(symbol);

            if (info == null)
            {
                operationResultMessage = "Failed to obtain symbol runtime session information.";
                return(false);
            }

            _delivery.SubscribeToData(info.Info, true, new DataSubscriptionInfo(true, false, null));
            _delivery.QuoteUpdateEvent += new QuoteUpdateDelegate(delivery_QuoteUpdateEvent);

            operationResultMessage = string.Empty;
            return(true);
        }
        /// <summary>
        /// Since the MT4 uses its slippage in points, we need to convert.
        /// </summary>
        /// <param name="normalValue"></param>
        /// <returns></returns>
        protected int ConvertSlippage(Symbol symbol, decimal?normalValue)
        {
            RuntimeDataSessionInformation session = null;

            //string convertedSymbol = ConvertSymbol(symbol);
            lock (this)
            {
                if (_dataSessions.ContainsKey(symbol))
                {
                    session = _dataSessions[symbol].SessionInformation;
                }
            }

            if (normalValue.HasValue == false)
            {// -1 encoded for full value.
                return(-1);
            }

            if (session == null)
            {
                SystemMonitor.Error("Session for symbol [" + symbol + "] not created yet. Slippage conversion failed.");
                return(-1);
            }

            return((int)((double)normalValue * Math.Pow(10, session.Info.DecimalPlaces)));
        }
Example #6
0
 /// <summary>
 /// Deserialization constructor.
 /// </summary>
 public LiveDemoSource(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _sessionInformation = (RuntimeDataSessionInformation)info.GetValue("sessionInformation", typeof(RuntimeDataSessionInformation));
     _dataStub           = (DataSourceStub)info.GetValue("dataStub", typeof(DataSourceStub));
     Construct();
 }
 /// <summary>
 ///
 /// </summary>
 public void AddSession(RuntimeDataSessionInformation sessionInformation)
 {
     lock (this)
     {
         _symbolsRunningSessions[sessionInformation.Info.Symbol] = new CombinedDataSubscriptionInformation(sessionInformation);
     }
 }
Example #8
0
        void manager_QuoteUpdatedEvent(FXCMConnectionManager manager, string symbolName, DataTick dataTick)
        {
            Symbol symbol = new Symbol(Symbol.SymbolGroup.Forex, symbolName);

            DataSourceStub dataSourceStub = _dataSourceStub;

            if (dataSourceStub == null)
            {
                return;
            }

            RuntimeDataSessionInformation sessionInformation = dataSourceStub.GetSymbolSessionInformation(symbol);

            if (sessionInformation == null)
            {
                return;
            }

            CombinedDataSubscriptionInformation info = dataSourceStub.GetUnsafeSessionSubscriptions(sessionInformation.Info);

            if (info != null && info.GetCombinedDataSubscription().QuoteSubscription)
            {
                dataSourceStub.UpdateQuote(sessionInformation.Info, new Quote(dataTick.Ask, dataTick.Bid, null, dataTick.DateTime), null);
                foreach (TimeSpan supportedPeriod in DefaultAvailablePeriods)
                {
                    dataSourceStub.UpdateDataHistory(sessionInformation.Info, new DataHistoryUpdate(supportedPeriod, new DataTick[] { dataTick }));
                }
            }
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        public bool RemoveSymbol(Symbol symbol)
        {
            ISourceDataDelivery delivery = _delivery;

            if (delivery != null)
            {
                RuntimeDataSessionInformation info = delivery.GetSymbolRuntimeSessionInformation(symbol);
                if (info == null)
                {
                    return(false);
                }

                delivery.SubscribeToData(info.Info, false, new DataSubscriptionInfo(true, false, null));
            }

            lock (this)
            {
                _symbolQuotes.Remove(symbol);
                if (_symbolQuotes.Count == 0)
                {// Release the delivery on last.
                    //_delivery.UnInitialize();
                    //_delivery.Dispose();
                    //_delivery = null;
                    _dataSourceId = null;
                }
            }

            return(true);
        }
Example #10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public LiveDemoDataAdapter(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _sessionInformation = (RuntimeDataSessionInformation)info.GetValue("sessionInformation", typeof(RuntimeDataSessionInformation));

            Construct();
            // Make sure to run Construct first, since it creates the timer instance.
            _liveDataTimer.Interval = info.GetDouble("timerInterval");
        }
Example #11
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public LiveDemoDataAdapter()
        {
            DataSourceStub stub = new DataSourceStub("Live Demo Data Source", false);

            _sessionInformation = new RuntimeDataSessionInformation(new DataSessionInfo(Guid.NewGuid(), "DEMO150", new Symbol("Unknown", "DEMO10D15"), 10000, 4), _period);
            base.SetStub(stub);

            Construct();
        }
        public RuntimeDataSessionInformation GetSymbolRuntimeSessionInformation(Symbol symbol)
        {
            RuntimeDataSessionInformation info = _sourceDataDelivery.GetSymbolRuntimeSessionInformation(symbol);

            if (info != null)
            {// Session info changes on each run (symbol stays the same), so keep it updated.
                _sessionInfo = info.Info;
            }

            return(info);
        }
        /// <summary>
        ///
        /// </summary>
        public RuntimeDataSessionInformation GetSymbolSessionRuntimeInformation(Symbol inputSymbol)
        {
            RuntimeDataSessionInformation information = _dataSourceStub.GetSymbolSessionInformation(inputSymbol);

            if (information == null)
            {
                return(new RuntimeDataSessionInformation(new DataSessionInfo(Guid.NewGuid(), "Historical Data " + inputSymbol.Name, inputSymbol, 1000, (int)GetInstrumentData(inputSymbol.Name, "Digits")), DefaultAvailablePeriods));
            }
            else
            {
                return(information);
            }
        }
        void Quotes_QuoteUpdateEvent(MBTradingQuote keeper, MBTradingQuote.SessionQuoteInformation information)
        {
            RuntimeDataSessionInformation session = _dataSourceStub.GetSymbolSessionInformation(information.Symbol);

            if (session != null)
            {
                _dataSourceStub.UpdateQuote(session.Info, information.Quote, null);
            }
            else
            {
                SystemMonitor.OperationWarning("Symbol session not found, quote missed.");
            }
        }
        public RuntimeDataSessionInformation GetSymbolSessionRuntimeInformation(Symbol symbol)
        {
            RuntimeDataSessionInformation information = _dataSourceStub.GetSymbolSessionInformation(symbol);

            if (information == null)
            {
                // It is also possible to have a symbol not in the initial BATS list.
                return(new RuntimeDataSessionInformation(new DataSessionInfo(Guid.NewGuid(), "Historical Data " + symbol.Name, symbol, 1000, 4), Period));
            }
            else
            {
                return(information);
            }
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        public RuntimeDataSessionInformation GetSymbolSessionRuntimeInformation(Symbol inputSymbol)
        {
            RuntimeDataSessionInformation information = _dataSourceStub.GetSymbolSessionInformation(inputSymbol);
            FXCMConnectionManager         manager     = Manager;

            if (information == null && manager != null)
            {
                return(new RuntimeDataSessionInformation(new DataSessionInfo(Guid.NewGuid(), inputSymbol.Name,
                                                                             inputSymbol, 1000, (int)manager.GetInstrumentData(inputSymbol.Name, "Digits")), DefaultAvailablePeriods));
            }
            else
            {
                return(information);
            }
        }
        /// <summary>
        ///
        /// </summary>
        public RuntimeDataSessionInformation GetSymbolSessionRuntimeInformation(Symbol inputSymbol)
        {
            // Filter the baseCurrency trough its name and what symbols we know of.
            Symbol?knownSymbol = EstablishSymbolUsage(inputSymbol, TimeSpan.FromSeconds(6));

            if (knownSymbol.HasValue == false)
            {// Failed to start / establish symbol usage.
                return(null);
            }

            DataSessionInfo sessionInfo = new DataSessionInfo(Guid.NewGuid(), knownSymbol.Value.Name,
                                                              knownSymbol.Value, DefaultLotSize, 5);

            RuntimeDataSessionInformation session = new RuntimeDataSessionInformation(sessionInfo);

            session.AvailableDataBarPeriods.AddRange(DefaultAvailablePeriods);
            return(session);
        }
        void PostQuoteUpdate(string forexPair, DataTick dataTick)
        {
            RuntimeDataSessionInformation sessionInformation = _dataSourceStub.GetSymbolSessionInformation(new Symbol("Forex", forexPair));

            if (sessionInformation != null &&
                _subscribedSymbols.ContainsKey(forexPair))
            {
                CombinedDataSubscriptionInformation info = _dataSourceStub.GetUnsafeSessionSubscriptions(sessionInformation.Info);

                if (info != null && info.GetCombinedDataSubscription().QuoteSubscription)
                {
                    _dataSourceStub.UpdateQuote(sessionInformation.Info, new Quote(dataTick.Ask, dataTick.Bid, null, dataTick.DateTime), null);
                    foreach (TimeSpan supportedPeriod in DefaultAvailablePeriods)
                    {
                        _dataSourceStub.UpdateDataHistory(sessionInformation.Info, new DataHistoryUpdate(supportedPeriod, new DataTick[] { dataTick }));
                    }
                }
            }
        }
        public IQuoteProvider ObtainQuoteProvider(ComponentId source, Symbol symbol)
        {
            if (source.IsEmpty || symbol.IsEmpty)
            {
                SystemMonitor.Warning("Source or symbol empty.");
                return(null);
            }

            lock (this)
            {
                if (_quoteProviders.ContainsKey(source) &&
                    _quoteProviders[source].ContainsKey(symbol))
                {
                    return(_quoteProviders[source][symbol]);
                }
            }

            ISourceDataDelivery delivery = ObtainDataDelivery(source);

            if (delivery == null)
            {
                SystemMonitor.OperationError("Failed to establish data delivery for quote provider.");
                return(null);
            }

            RuntimeDataSessionInformation session = delivery.GetSymbolRuntimeSessionInformation(symbol);

            if (session == null)
            {
                SystemMonitor.OperationError("Failed to establish runtime session information for symbol [" + symbol.Name + "]");
                return(null);
            }

            QuoteProvider provider = new QuoteProvider(session.Info);

            // Make sure to *add before setting up* the initial paramters,
            // since a call from them can get back to this method, and cause a stack overflow.
            AddElement(source, symbol, provider);

            provider.SetInitialParameters(delivery);

            return(provider);
        }
        public IDataBarHistoryProvider ObtainDataBarHistoryProvider(ComponentId source, Symbol symbol, TimeSpan period)
        {
            if (source.IsEmpty || symbol.IsEmpty)
            {
                SystemMonitor.Warning("Source or symbol empty.");
                return(null);
            }

            lock (this)
            {
                if (_dataBarProviders.ContainsKey(source) &&
                    _dataBarProviders[source].ContainsKey(symbol) &&
                    _dataBarProviders[source][symbol].ContainsKey(period))
                {
                    return(_dataBarProviders[source][symbol][period]);
                }
            }

            ISourceDataDelivery delivery = GetDataDelivery(source);

            if (delivery == null)
            {
                SystemMonitor.OperationError("Failed to establish data delivery for quote provider.");
                return(null);
            }

            RuntimeDataSessionInformation session = delivery.GetSymbolRuntimeSessionInformation(symbol);

            if (session == null)
            {
                SystemMonitor.OperationError("Failed to establish runtime session information for symbol [" + symbol.Name + "]");
            }

            DataBarHistoryProvider provider = new DataBarHistoryProvider(delivery, session.Info, period, null);

            // By default assign a volume indicator.
            provider.Indicators.AddIndicator(new VolumeCustom());

            AddElement(source, symbol, period, provider);

            return(provider);
        }
        /// <summary>
        ///
        /// </summary>
        public List <RuntimeDataSessionInformation> GetSymbolsSessionInformation(Symbol[] symbols)
        {
            List <RuntimeDataSessionInformation> informations = new List <RuntimeDataSessionInformation>();

            lock (this)
            {
                foreach (Symbol symbol in symbols)
                {
                    if (_symbolsRunningSessions.ContainsKey(symbol))
                    {
                        RuntimeDataSessionInformation info = _symbolsRunningSessions[symbol].SessionInformation;
                        if (info != null)
                        {
                            informations.Add(info);
                        }
                    }
                }
            }

            return(informations);
        }
        public IDataTickHistoryProvider ObtainDataTickHistoryProvider(ComponentId source, Symbol symbol)
        {
            if (source.IsEmpty || symbol.IsEmpty)
            {
                SystemMonitor.Warning("Source or symbol empty.");
                return(null);
            }

            lock (this)
            {
                if (_dataTickProviders.ContainsKey(source) &&
                    _dataTickProviders[source].ContainsKey(symbol))
                {
                    return(_dataTickProviders[source][symbol]);
                }
            }

            ISourceDataDelivery delivery = ObtainDataDelivery(source);

            if (delivery == null)
            {
                SystemMonitor.OperationError("Failed to establish data delivery for quote provider.");
                return(null);
            }

            RuntimeDataSessionInformation session = delivery.GetSymbolRuntimeSessionInformation(symbol);

            if (session == null)
            {
                SystemMonitor.OperationError("Failed to establish runtime session information for symbol [" + symbol.Name + "]");
                return(null);
            }

            DataTickHistoryProvider provider = new DataTickHistoryProvider(delivery, session.Info);

            AddElement(source, symbol, provider);

            return(provider);
        }
        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]);
            }
        }
 /// <summary>
 ///
 /// </summary>
 public CombinedDataSubscriptionInformation(RuntimeDataSessionInformation sessionInformation)
 {
     _sessionInformation = sessionInformation;
 }
        /// <summary>
        /// Get dataDelivery sessions for baseCurrency, source must be dataDelivery source.
        /// </summary>
        public DataSessionInfo?GetSymbolDataSessionInfo(ComponentId sourceId, Symbol symbol)
        {
            lock (_cachedDataSessions)
            {
                if (_cachedDataSessions.ContainsKey(sourceId) == false)
                {
                    _cachedDataSessions.Add(sourceId, new Dictionary <Symbol, DataSessionInfo?>());
                }

                if (_cachedDataSessions[sourceId].ContainsKey(symbol) == false)
                {
                    _cachedDataSessions[sourceId].Add(symbol, null);
                }
                else if (_cachedDataSessions[sourceId][symbol].HasValue)
                {
                    return(_cachedDataSessions[sourceId][symbol]);
                }
            }

            if (IsLocalSource(sourceId))
            {
                ISourceDataDelivery delivery = ObtainDataDelivery(sourceId);
                if (delivery == null)
                {
                    SystemMonitor.OperationError("Failed to establish local delivery.");
                    return(null);
                }

                RuntimeDataSessionInformation session = delivery.GetSymbolRuntimeSessionInformation(symbol);
                if (session == null)
                {
                    SystemMonitor.OperationError("Failed to establish symbol session [" + symbol.Name + "].");
                    return(null);
                }
                return(session.Info);
            }

            List <ArbiterClientId?> sourcePath;

            if (GetSourcePath(sourceId, out sourcePath) == false)
            {
                SystemMonitor.OperationError("Failed to establish source path.");
                return(null);
            }

            RequestSymbolsRuntimeInformationMessage request = new RequestSymbolsRuntimeInformationMessage(new Symbol[] { symbol });
            ResponceMessage responce = this.SendAndReceiveForwarding <ResponceMessage>(sourcePath, request);

            if (responce != null && responce.OperationResult)
            {
                SessionsRuntimeInformationMessage responceMessage = (SessionsRuntimeInformationMessage)responce;
                if (responceMessage.Informations.Count > 0)
                {
                    lock (_cachedDataSessions)
                    {
                        _cachedDataSessions[sourceId][symbol] = responceMessage.Informations[0].Info;
                    }

                    return(responceMessage.Informations[0].Info);
                }
            }

            return(null);
        }
Example #26
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public LiveDemoSource()
 {
     _dataStub           = new DataSourceStub(Name, false);
     _sessionInformation = new RuntimeDataSessionInformation(new DataSessionInfo(Guid.NewGuid(), "DEMO150", new Symbol("Unknown", "DEMO10D15"), 10000, 4), _period);
     Construct();
 }
        void CreateSessionPane(bool trading)
        {
            if (listViewQuotes.SelectedItems.Count < 1 || Component.Delivery == null || Component.DataSourceId.HasValue == false)
            {
                return;
            }

            ListViewItem    item = listViewQuotes.SelectedItems[0];
            LocalExpertHost host = new LocalExpertHost(item.Text, typeof(ManualTradeExpert));

            Component.Platform.RegisterComponent(host);

            RuntimeDataSessionInformation info = Component.Delivery.GetSymbolRuntimeSessionInformation((Symbol)item.Tag);

            if (info == null)
            {
                SystemMonitor.OperationError("Failed to obtain symbol session, operation can not be performed.");
                MessageBox.Show("Failed to obtain symbol session, operation can not be performed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string operationResultMessage;

            ComponentId?tradeSourceId = null;

            if (trading)
            {
                SortedDictionary <int, List <ComponentId> > compatibleExecutioners =
                    Component.GetCompatibleOrderExecutionSources(Component.DataSourceId.Value, info.Info.Symbol, SourceTypeEnum.Live | SourceTypeEnum.OrderExecution);

                if (compatibleExecutioners.Count == 0 ||
                    compatibleExecutioners[GeneralHelper.EnumerableFirstThrows <int>(compatibleExecutioners.Keys)].Count == 0)
                {
                    MessageBox.Show("Failed to find order execution source for this symbol. Trading can not be initiated.");
                    return;
                }

                tradeSourceId = compatibleExecutioners[GeneralHelper.EnumerableFirstThrows <int>(compatibleExecutioners.Keys)][0];
            }

            PlatformExpertSession session = host.CreateExpertSession(info.Info, Component.DataSourceId.Value,
                                                                     tradeSourceId, false, out operationResultMessage);

            if (session == null)
            {
                SystemMonitor.OperationError(operationResultMessage);
                MessageBox.Show(operationResultMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (host.RegisterExpertSession(session))
            {
                // Try to run a 1hour chart, or if not, any chart available.
                bool oneHourFound = false;
                foreach (TimeSpan span in session.DataProvider.AvailableDataBarProviderPeriods)
                {
                    if (span == TimeSpan.FromHours(1))
                    {
                        session.DataProvider.ObtainDataBarProvider(TimeSpan.FromHours(1));
                        oneHourFound = true;
                        break;
                    }
                }

                if (oneHourFound == false && session.DataProvider.AvailableDataBarProviderPeriods.Length > 0)
                {
                    session.DataProvider.ObtainDataBarProvider(session.DataProvider.AvailableDataBarProviderPeriods[0]);
                }

                // Allow the pending control requests to be created and performed before floating it.
                this.BeginInvoke(new GeneralHelper.GenericDelegate <LocalExpertHost>(SetControlFloat), host);
            }
            else
            {
                SystemMonitor.OperationError("Failed to register session.");
                MessageBox.Show("Failed to register session.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }