예제 #1
0
 //subscribe some object to receive New Deals
 public void SubscribeDealSink(ref clsDealSink myDealSink)
 {
     if (!CheckIfMannagerWorks())
     {
         return;
     }
     var resDealSink    = myDealSink.RegisterSink();
     var requestResult1 = m_manager.DealSubscribe(myDealSink);
 }
예제 #2
0
        public bool Start(string server, UInt64 login, string password)
        {
            //--- check manager
            if (m_manager == null)
            {
                return(false);
            }
            //--- check arguments
            if (server == null || login == 0 || password == null)
            {
                m_manager.LoggerOut(EnMTLogCode.MTLogErr, "Dealer: starting failed with bad arguments");
                return(false);
            }
            //--- do not let exception get out here
            try
            {
                //--- check if dealer is started already
                if (m_thread_dealer != null)
                {
                    //--- dealer thread is running
                    if (m_thread_dealer.IsAlive)
                    {
                        return(false);
                    }
                    //---
                    m_thread_dealer = null;
                }
                //--- save authorize info
                m_server   = server;
                m_login    = login;
                m_password = password;
                //--- subscribe for notifications
                if (m_manager.Subscribe(this) != MTRetCode.MT_RET_OK)
                {
                    return(false);
                }
                //--- subscribe for requests
                if (m_manager.DealSubscribe(_dealSink) != MTRetCode.MT_RET_OK)
                {
                    return(false);
                }
                //--- start dealing thread
                m_stop_flag = 0;
                m_connected = 0;
                //--- start thread
                //m_thread_dealer = new Thread(DealerFunc, STACK_SIZE_COMMON);
                //m_thread_dealer.Start();
                //--- done

                MTRetCode res = m_manager.Connect(m_server, m_login, m_password, null,
                                                  CIMTManagerAPI.EnPumpModes.PUMP_MODE_FULL,
                                                  MT5_CONNECT_TIMEOUT);

                if (m_manager.DealerStart() != MTRetCode.MT_RET_OK)
                {
                }

                return(true);
            }
            catch (Exception ex)
            {
                if (m_manager != null)
                {
                    m_manager.LoggerOut(EnMTLogCode.MTLogErr, "Dealer: starting failed - {0}", ex.Message);
                }
            }
            //--- done with errors
            return(false);
        }