Ejemplo n.º 1
0
        //TODO: handleRemoveSSPinSMRequest
        public async Task <SMSignalRemoveResponse> RemoveSSPinSM(
            SMSignalRemoveRequest ptr, CancellationToken cancellationToken)
        {
            m_ptrLogger.LogOk("START");

            await _signalService.DeleteSSPinSM(ptr._smSignal, cancellationToken);

            bool ret = true;
            SMSignalRemoveResponse ptrResp = new SMSignalRemoveResponse();//MT_RemoveSMSignalResponse_ID

            ptrResp._retCode       = ret == true ? RC_OK : RC_ERROR;
            ptrResp._dataTransMode = ptr._dataTransMode;
            CppHelper.memcpy(ref ptrResp._smSignal, ptr._smSignal);
            //SentDataUsingSocketID(ptrResp, MT_RemoveSMSignalResponse_ID, ptr._header._socketID);
            if (ret)
            {
                //await RemoveFollowerAsync(ptr._smSignal._smMT4Login, ptr._smSignal._sspMT4Login,
                //    ptr._smSignal._sspMT4ServerIndex);
                //removeFollowerVolume(ptr._smSignal._sspSignalIndex, ptr._smSignal._sspMT4Login, ptr._smSignal._followerMT4Login, ptr._smSignal._followervolume);

                m_ptrLogger.LogInfo(
                    "SSP %d in SM %d deleted", ptr._smSignal._sspMasterLogin, ptr._smSignal._smMasterLogin);
            }
            else
            {
                m_ptrLogger.LogError(
                    "Unable to delete %d SSP from %d SM", ptr._smSignal._sspMasterLogin, ptr._smSignal._smMasterLogin);
            }

            m_ptrLogger.LogOk("END");
            return(ptrResp);
        }
Ejemplo n.º 2
0
        //TODO: handleSSPFollowerRequest
        public async Task <AddSSPFollowerResponse> AddSSPFollower(
            AddSSPFollowerRequest ptr, CancellationToken cancellationToken)
        {
            AddSSPFollowerResponse ptrResp = null;

            m_ptrLogger.LogOk("START");

            if (ptr._dataTransMode == DT_TRANS_ADD)
            {
                await _followerService.InsertSSPFollower(ptr._sspfollower, cancellationToken);

                bool ret = true;
                ptrResp                = new AddSSPFollowerResponse(); //MT_AddSSPFollowerResponse_ID
                ptrResp._retCode       = ret == true ? RC_OK : RC_ERROR;
                ptrResp._dataTransMode = ptr._dataTransMode;
                CppHelper.memcpy(ref ptrResp._sspfollower, ptr._sspfollower);
                //SentDataUsingSocketID(ptrResp, MT_AddSSPFollowerResponse_ID, ptr._header._socketID);
                if (ret)
                {
                    //await AddFollowerAsync(ptr._sspfollower._sspMT4Login, ptr._sspfollower._followerMT4Login,
                    //    ptr._sspfollower._followerMT4ServerIndex, cancellationToken);
                    //await AddFollowerVolumeAsync(ptr._sspfollower._sspSignalIndex,
                    //    ptr._sspfollower._followerMT4ServerIndex, ptr._sspfollower._followerMT4Login,
                    //    ptr._sspfollower._followervolume, cancellationToken);

                    m_ptrLogger.LogInfo(
                        "SSP follower added. Follower master login: %d SSP master login : %d SignalIndex: %d",
                        ptr._sspfollower._followerMasterLogin, ptr._sspfollower._sspMasterLogin, ptr._sspfollower._sspSignalIndex);
                }
                else
                {
                    m_ptrLogger.LogError(
                        "Unable to add SSP follower. Follower master login: %d SSP master login : %d SignalIndex: %d",
                        ptr._sspfollower._followerMasterLogin, ptr._sspfollower._sspMasterLogin, ptr._sspfollower._sspSignalIndex);
                }
            }
            else if (ptr._dataTransMode == DT_TRANS_MODIFY)
            {
                await _followerService.ModifySSPFollower(ptr._sspfollower, cancellationToken);

                bool ret = true;
                ptrResp                = new AddSSPFollowerResponse(); // MT_AddSSPFollowerResponse_ID
                ptrResp._retCode       = ret == true ? RC_OK : RC_ERROR;
                ptrResp._dataTransMode = ptr._dataTransMode;
                CppHelper.memcpy(ref ptrResp._sspfollower, ptr._sspfollower);
                //SentDataUsingSocketID(ptrResp, MT_AddSSPFollowerResponse_ID, ptr._header._socketID);
                if (ret)
                {
                    //await UpdateFollowerVolumeAsync(ptr._sspfollower._sspSignalIndex, ptr._sspfollower._followerMT4ServerIndex,
                    //    ptr._sspfollower._followerMT4Login, ptr._sspfollower._followervolume, cancellationToken);

                    m_ptrLogger.LogInfo(
                        "SSP follower modified. Follower master login: %d SSP master login : %d SignalIndex: %d",
                        ptr._sspfollower._followerMasterLogin, ptr._sspfollower._sspMasterLogin, ptr._sspfollower._sspSignalIndex);
                }
                else
                {
                    m_ptrLogger.LogError(
                        "Unable to modify SSP follower. Follower master login: %d SSP master login : %d SignalIndex: %d",
                        ptr._sspfollower._followerMasterLogin, ptr._sspfollower._sspMasterLogin, ptr._sspfollower._sspSignalIndex);
                }
            }
            else if (ptr._dataTransMode == DT_TRANS_DELETE)
            {
                await _followerService.DeleteSSPFollower(ptr._sspfollower, cancellationToken);

                bool ret = true;
                ptrResp                = new AddSSPFollowerResponse(); // MT_AddSSPFollowerResponse_ID
                ptrResp._retCode       = ret == true ? RC_OK : RC_ERROR;
                ptrResp._dataTransMode = ptr._dataTransMode;
                CppHelper.memcpy(ref ptrResp._sspfollower, ptr._sspfollower);
                //SentDataUsingSocketID(ptrResp, MT_AddSSPFollowerResponse_ID, ptr._header._socketID);
                if (ret)
                {
                    //await RemoveFollowerAsync(ptr._sspfollower._sspMT4Login,
                    //    ptr._sspfollower._followerMT4Login,
                    //    ptr._sspfollower._followerMT4ServerIndex, cancellationToken);
                    //await RemoveFollowerVolumeAsync(ptr._sspfollower._sspSignalIndex,
                    //    ptr._sspfollower._followerMT4ServerIndex, ptr._sspfollower._followerMT4Login,
                    //    ptr._sspfollower._followervolume, cancellationToken);

                    m_ptrLogger.LogInfo(
                        "SSP follower deleted. Follower master login: %d SSP master login : %d SignalIndex: %d",
                        ptr._sspfollower._followerMasterLogin, ptr._sspfollower._sspMasterLogin, ptr._sspfollower._sspSignalIndex);
                }
                else
                {
                    m_ptrLogger.LogError(
                        "Unable to delete SSP follower. Follower master login: %d SSP master login : %d SignalIndex: %d",
                        ptr._sspfollower._followerMasterLogin, ptr._sspfollower._sspMasterLogin, ptr._sspfollower._sspSignalIndex);
                }
            }

            m_ptrLogger.LogOk("END");
            return(ptrResp);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// WitFXMT4ServerBL.onMT4Response
        /// </summary>
        private async Task OnResponseAsync(
            ReturnCode errorcode, string errormessage, eMT4ServerType serverIndex, MT4REQ reqType,
            eOrderStatus trans_status, int masterLogin, /*int orderOrLogin,*/ Guid server_trans_id,
            eAccountType accType, MT4REQMODE reqMode, MT4Request request, CancellationToken cancellationToken)
        {
            Debug.Assert(masterLogin > 0);
            //m_ptrMySqlWrapper.insertLog(Utilities.LOG_INFO,masterLogin,orderOrLogin,"X",)
            if (reqType == MT4REQ.MT4REQ_NEW_ACCOUNT)
            {
                var mt4Login = request.User?.login ?? 0;

                if (trans_status == eOrderStatus.ORD_STAT_EXECUTED)
                {
                    Debug.Assert(mt4Login > 0);
                    m_ptrLogger.LogInfo($"EXECUTED : MT4 Account {mt4Login}, master Login {masterLogin}, AccountType: {accType}");
                    MT4Account acc = new MT4Account();
                    //memset(&acc, 0, sizeof(MT4Account));
                    acc._accountType    = accType;
                    acc._masterLogin    = masterLogin;
                    acc._mt4Login       = mt4Login;
                    acc._mt4ServerIndex = serverIndex;

                    //if (serverIndex == SRV_TYPE_DEMO)
                    //{
                    //    Demo.insertMT4Account(orderOrLogin);
                    //}
                    //else
                    //{
                    //    Live.insertMT4Account(orderOrLogin);
                    //}

                    lock (_mt4LoginsByServerIndex)
                        AddMt4LoginNoLock(serverIndex, mt4Login);

                    await _mt4AccountService.InsertMT4Account(acc, cancellationToken);

                    //if (!)
                    //{
                    //    m_ptrLogger.LogError("Unable to insert MT4 account for masterlogin: %d MT4 Login: %d in database", masterLogin, orderOrLogin);
                    //}
                    //else
                    //{

                    #region Rebate
                    //TODO: Claudia: rebate
                    //if (accType == ACC_TYPE_REBATE)
                    //{
                    //    Dictionary<int, int>.iterator it2;

                    //    //lock (m_SyncMapMt4Master)
                    //    //{

                    //    it2 = m_mapMasterRebateAcc.find(masterLogin);
                    //    if (it2 == m_mapMasterRebateAcc.end())
                    //    {
                    //        m_mapMasterRebateAcc.insert(new ValueTuple<int, int>(masterLogin, orderOrLogin));
                    //    }

                    //    //}
                    //}
                    #endregion

                    ////else //if (accType != ACC_TYPE_REBATE)
                    ////{
                    //Dictionary<bool, Dictionary<int, int>>.iterator it1;
                    ////Dictionary<int, int>.iterator it2;

                    ////lock (m_SyncMapMt4Master)
                    ////{

                    //bool isDemoServer = serverIndex == SRV_TYPE_DEMO ? true : false;
                    //it1 = m_mapMT4MasterLogin.find(isDemoServer);
                    //if (it1 == m_mapMT4MasterLogin.end())
                    //{
                    //    Dictionary<int, int> mp2 = new Dictionary<int, int>();
                    //    m_mapMT4MasterLogin.insert(new ValueTuple<bool, Dictionary<int, int>>(isDemoServer, mp2));
                    //    it1 = m_mapMT4MasterLogin.find(isDemoServer);
                    //}
                    //it1.second.insert(new ValueTuple<int, int>(orderOrLogin, masterLogin));



                    ////}
                    ////}
                    ////}


                    if (accType == eAccountType.ACC_TYPE_SSP)
                    {
                        await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken);

                        await _signalService.UpdateSSPSignalMT4Login(server_trans_id, mt4Login, cancellationToken);

                        //fetchAllSignal();
                        //fetchAllSSPSignal();
                        //fetchAllSMSignal();
                        //insertDBTransmitData(masterLogin, FDMT_Signal_ID);
                        //insertDBTransmitData(masterLogin, FDMT_SSPSignal_ID);
                    }
                    else if (accType == eAccountType.ACC_TYPE_SM)
                    {
                        await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken);

                        await _signalService.UpdateSMSignalMT4Login(server_trans_id, mt4Login, cancellationToken);

                        //fetchAllSignal();
                        //fetchAllSSPSignal();
                        //fetchAllSMSignal();

                        //insertDBTransmitData(masterLogin, FDMT_Signal_ID);
                        //insertDBTransmitData(masterLogin, FDMT_SMSignal_ID);
                    }

                    var m_masterUserSetting = await _masterSettingsService.GetCachedMasterSettingsAsync(cancellationToken);

                    if (accType == eAccountType.ACC_TYPE_FOLLOWER_DEMO || accType == eAccountType.ACC_TYPE_SSP || accType == eAccountType.ACC_TYPE_SM)
                    {
                        MT4Request ptrMT4Req4 = (MT4Request) new MT4Request();
                        //memset(ptrMT4Req4, 0, sizeof(MT4Request));
                        //ptrMT4Req4.newLoginOrOrderID = orderOrLogin; // Alexey
                        ptrMT4Req4.masterLogin = masterLogin;
                        ptrMT4Req4.reqType     = MT4REQ.MT4REQ_BALANCE;
                        //ptrMT4Req4.socketID = socketID;
                        ptrMT4Req4.status        = eOrderStatus.ORD_STAT_RECVD;
                        ptrMT4Req4.serverTransID = TransactionService.NewTransactionId();
                        ptrMT4Req4.ptrData       = new MT4OrderInfo();
                        //memset(ptrMT4Req4.ptrData, 0, sizeof(MT4OrderInfo));
                        MT4OrderInfo ptrOrd = (MT4OrderInfo)ptrMT4Req4.ptrData;
                        ptrOrd._accountType    = accType;
                        ptrOrd._masterLogin    = masterLogin;
                        ptrOrd._mt4Login       = mt4Login;
                        ptrOrd._mt4ServerIndex = serverIndex;
                        ptrOrd._orderTransMode = eMT4OrderTransMode.ORD_TRANS_CLOSE;
                        ptrOrd._orderType      = eMT4OrderType.ORD_TYPE_BALANCE;
                        ptrOrd._price          = request.deposit;
                        if (ptrOrd._price == 0)
                        {
                            if (accType == eAccountType.ACC_TYPE_FOLLOWER_DEMO)
                            {
                                ptrOrd._price = m_masterUserSetting._deposit_followerDemo;
                            }
                            else if (accType == eAccountType.ACC_TYPE_SSP)
                            {
                                ptrOrd._price = m_masterUserSetting._deposit_SSP;
                            }
                            else if (accType == eAccountType.ACC_TYPE_SM)
                            {
                                ptrOrd._price = m_masterUserSetting._deposit_SM;
                            }
                        }

                        Demo.insertMT4Request(ptrMT4Req4);
                    }
                    else if (accType == eAccountType.ACC_TYPE_FOLLOWER_LIVE)
                    {
                        MT4Request ptrMT4Req4 = (MT4Request) new MT4Request();
                        //memset(ptrMT4Req4, 0, sizeof(MT4Request));
                        //ptrMT4Req4.newLoginOrOrderID = orderOrLogin; // Alexey
                        ptrMT4Req4.masterLogin = masterLogin;
                        ptrMT4Req4.reqType     = MT4REQ.MT4REQ_BALANCE;
                        //ptrMT4Req4.socketID = socketID;
                        ptrMT4Req4.status        = eOrderStatus.ORD_STAT_RECVD;
                        ptrMT4Req4.serverTransID = TransactionService.NewTransactionId();
                        ptrMT4Req4.ptrData       = new MT4OrderInfo();
                        //memset(ptrMT4Req4.ptrData, 0, sizeof(MT4OrderInfo));
                        MT4OrderInfo ptrOrd = (MT4OrderInfo)ptrMT4Req4.ptrData;
                        ptrOrd._accountType    = accType;
                        ptrOrd._masterLogin    = masterLogin;
                        ptrOrd._mt4Login       = mt4Login;
                        ptrOrd._mt4ServerIndex = serverIndex;
                        ptrOrd._orderTransMode = eMT4OrderTransMode.ORD_TRANS_CLOSE;
                        ptrOrd._orderType      = eMT4OrderType.ORD_TYPE_BALANCE;
                        ptrOrd._price          = request.deposit;
                        if (ptrOrd._price == 0)
                        {
                            ptrOrd._price = m_masterUserSetting._deposit_followerLive;
                        }
                        Live.insertMT4Request(ptrMT4Req4);
                    }

                    var ptrResp = new MT4AccountResponse(); //MT_MT4AccountResponse_ID
                    CppHelper.memcpy(ref ptrResp._account, acc);
                    _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_MT4AccountResponse_ID, masterLogin);
                }
                else if (trans_status == eOrderStatus.ORD_STAT_PROCESSING)
                {
                    // Claudia: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request
                    Debug.Assert(masterLogin > 0);
                    m_ptrLogger.LogInfo("PROCESSING : MT4 Account %d master Login %d AccountType: %d", mt4Login, masterLogin, accType);
                    var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID
                    ptrResp._serverTransID = server_trans_id;
                    ptrResp._requestMode   = reqMode;
                    ptrResp._retCode       = (eReturnCode)trans_status;
                    //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID);
                    _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin);
                }
                else if (trans_status == eOrderStatus.ORD_STAT_REJECTED)
                {
                    // Claudia: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request
                    Debug.Assert(masterLogin > 0);
                    m_ptrLogger.LogInfo("REJECTED : MT4 Account %d master Login %d AccountType: %d", mt4Login, masterLogin, accType);
                    if (accType == eAccountType.ACC_TYPE_SSP)
                    {
                        await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true);

                        await _signalService.UpdateSSPSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true);
                    }
                    if (accType == eAccountType.ACC_TYPE_SM)
                    {
                        await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true);

                        await _signalService.UpdateSMSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true);
                    }
                    var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID
                    ptrResp._serverTransID = server_trans_id;
                    ptrResp._requestMode   = reqMode;
                    ptrResp._retCode       = (eReturnCode)trans_status;
                    ptrResp._mt4errorcode  = errorcode;
                    CppHelper.strcpy(out ptrResp._mt4errormessage, errormessage);
                    //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID);
                    _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin);
                }
                //insertDBTransmitData(masterLogin, FDMT_MasterUser_ID);
                //insertDBTransmitData(masterLogin, FDMT_MT4Account_ID);
                //insertDBTransmitData(masterLogin, FDMT_SSPSignal_ID);
                //insertDBTransmitData(masterLogin, FDMT_SSPSignal_ID);
            }
            else
            {
                var orderId = request.OrderInfo?._orderID ?? 0;

                if (trans_status == eOrderStatus.ORD_STAT_PROCESSING)
                {
                    // Alexey: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request
                    Debug.Assert(masterLogin > 0 && server_trans_id != Guid.Empty);
                    m_ptrLogger.LogInfo($"PROCESSING : Order {orderId}, master Login {masterLogin}, UID: {server_trans_id}");
                    var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID
                    ptrResp._serverTransID = server_trans_id;
                    ptrResp._requestMode   = reqMode;
                    ptrResp._retCode       = (eReturnCode)trans_status;
                    //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID);
                    _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin);
                }
                else if (trans_status == eOrderStatus.ORD_STAT_REJECTED)
                {
                    // Alexey: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request
                    Debug.Assert(masterLogin > 0 && server_trans_id != Guid.Empty);
                    m_ptrLogger.LogInfo($"REJECTED : Order {orderId}, master Login {masterLogin}, UID: {server_trans_id}");
                    var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID
                    ptrResp._serverTransID = server_trans_id;
                    ptrResp._requestMode   = reqMode;
                    ptrResp._retCode       = (eReturnCode)trans_status;
                    ptrResp._mt4errorcode  = errorcode;
                    CppHelper.strcpy(out ptrResp._mt4errormessage, errormessage);
                    //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID);
                    _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin);
                }
                else if (trans_status == eOrderStatus.ORD_STAT_EXECUTED)
                {
                    if (reqMode == MT4REQMODE.OPEN_TRADE)
                    {
                        Debug.Assert(server_trans_id != Guid.Empty && orderId > 0 && request.Order != null && request.Order.OrderId == 0);
                        request.Order.OrderId = orderId;
                        await _orderService.InsertAsync(request.Order, cancellationToken);

                        //    updateTransLinking(server_trans_id, orderOrLogin);
                    }
                    //if (reqMode == MT4REQMODE.CLOSE_TRADE || reqMode == MT4REQMODE.DELETE_TRADE)
                    //{
                    //    removeTransLinking(server_trans_id);
                    //}
                    Debug.Assert(masterLogin > 0 && server_trans_id != Guid.Empty);
                    m_ptrLogger.LogInfo($"EXECUTED : Order {orderId}, master Login {masterLogin}, UID: {server_trans_id}");
                    var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID
                    ptrResp._serverTransID = server_trans_id;
                    ptrResp._requestMode   = reqMode;
                    ptrResp._retCode       = (eReturnCode)trans_status;
                    //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID);
                    _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin);
                }
            }
        }
Ejemplo n.º 4
0
        public async Task StartAsync(CancellationToken cancellationToken, bool startThreads = true)
        {
            Debug.Assert(!_isStarting);

            if (_isStarting)
            {
                throw new InvalidOperationException();
            }

            _isStarting = true;
            _factory    = ManagerHost.CreateFactory(HandleException);
            CheckFactory();
            _factory.WinsockStartup();
            var m_masterUserSetting = await _masterSettingsService.GetCachedMasterSettingsAsync(cancellationToken);

            var mt4Accounts = await _mt4AccountService.GetAllMT4Accounts(cancellationToken);

            lock (_mt4LoginsByServerIndex)
                foreach (var mt4Account in mt4Accounts)
                {
                    AddMt4LoginNoLock(mt4Account._mt4ServerIndex, mt4Account._mt4Login);
                }

            m_ptrLogger.LogInfo("Initializng DEMO MT4 Manager");
            Debug.Assert(_demo == null);
            _demo = new WitFXServerConnector(
                eMT4ServerType.SRV_TYPE_DEMO, this, _factory,
                m_masterUserSetting._demoServer, m_masterUserSetting._demoManagerLogin,
                m_masterUserSetting._demoManagerPassword, _baseLogger, true, true,
                startThreads: startThreads);

            CppHelper.memcpy(ref _demo.m_masterUserSetting, m_masterUserSetting);

            //_demo.setMT4SocialUsers(m_mapMT4MasterLogin);
            //_demo.setMT4ResponseFunPtr(onMT4Response);
            //_demo.setMarketDataFunPtr(onMarketData);
            //_demo.setSymbolInfoFunPtr(onSymbolInfo);
            //_demo.setOnTradeFunPtr(onTradeResponse);
            //_demo.setOnMarginFunPtr(onMarginLevelResponse);

            m_ptrLogger.LogInfo("Initializng LIVE MT4 Manager");
            Debug.Assert(_live == null);
            _live = new WitFXServerConnector(
                eMT4ServerType.SRV_TYPE_LIVE, this, _factory,
                m_masterUserSetting._liveServer, m_masterUserSetting._liveManagerLogin,
                m_masterUserSetting._liveManagerPassword, _baseLogger, true, true,
                startThreads: startThreads);

            CppHelper.memcpy(ref _live.m_masterUserSetting, m_masterUserSetting);

            //_live.setMT4SocialUsers(m_mapMT4MasterLogin);
            //_live.setMT4ResponseFunPtr(onMT4Response);
            //_live.setOnTradeFunPtr(onTradeResponse);
            //_live.setOnMarginFunPtr(onMarginLevelResponse);

            if (startThreads)
            {
                if (_demo.IsAPIValid())
                {
                    m_ptrLogger.LogInfo("Starting DEMO MT4 Manager connection...");
                    _demo.startNormalManager();
                }
                else
                {
                    m_ptrLogger.LogError("MT4 MANAGER API IS NOT VALID");
                }
                if (_live.IsAPIValid())
                {
                    m_ptrLogger.LogInfo("Starting LIVE MT4 Manager connection...");
                    _live.startNormalManager();
                }
                else
                {
                    m_ptrLogger.LogError("MT4 MANAGER API IS NOT VALID");
                }

                var demoUpdateWorker = _updateWorkerFactory(eMT4ServerType.SRV_TYPE_DEMO);
                await demoUpdateWorker.ConfigureAsync(cancellationToken);

                _workerManager.StartWorker(demoUpdateWorker);

                var liveUpdateWorker = _updateWorkerFactory(eMT4ServerType.SRV_TYPE_LIVE);
                await liveUpdateWorker.ConfigureAsync(cancellationToken);

                _workerManager.StartWorker(liveUpdateWorker);
            }
        }