Ejemplo n.º 1
0
        static void Main()
        {
            // Create a client
            InstanceContext   site   = new InstanceContext(null, new Client());
            TradeMirrorClient client = new TradeMirrorClient(site);

            if (client.Subscribe("1413684", "forexsuccess", 1413684))
            {
                Logger.Info("Subscribed", OType.FullName, "Main");
                Console.WriteLine("Subscribed");
                Console.WriteLine();
                Console.WriteLine("Press ENTER to unsubscribe and shut down client");
            }
            else
            {
                Logger.Info("Invalid Credentials", OType.FullName, "Main");
                Console.WriteLine("Invalid credentials");
            }

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();

            client.Unsubscribe("1413684", "forexsuccess", 1413684);
            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public MainWindowViewModel()
        {
            try
            {
                this.ConnectCommand    = new ConnectCommand(this);
                this.DisconnectCommand = new DisconnectCommand(this);

                this._currentDispatcher = Dispatcher.CurrentDispatcher;

                // Create a client
                _site          = new InstanceContext(null, this);
                _site.Closed  += CommunicationObjectOnClosed;
                _site.Faulted += CommunicationObjectOnClosed;

                _client = new TradeMirrorClient(_site);

                _heartbeatTimer           = new Timer(AcceptedDelaySeconds * 1000);
                _heartbeatTimer.Elapsed  += HeartbeatTimerElapsed;
                _heartbeatTimer.AutoReset = true;

                UpdateUI("Disconnected");
                if (!InitializeCredentials())
                {
                    SetAccountID();
                }
                else
                {
                    IsSavePasswordChecked = true;
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, OType.FullName, "MainWindowViewModel");
            }
        }
Ejemplo n.º 3
0
        public AutoFXProfitsClientTerminal()
        {
            try
            {
                InitializeComponent();

                // Create a client
                _site   = new InstanceContext(null, this);
                _client = new TradeMirrorClient(_site);

                _heartbeatTimer           = new Timer(AcceptedDelaySeconds * 1000);
                _heartbeatTimer.Elapsed  += HeartbeatTimerElapsed;
                _heartbeatTimer.AutoReset = true;

                UpdateUI("Disconnected");

                if (!InitializeCredentials())
                {
                    SetAccountID();
                }
                else
                {
                    IsSavePasswordChecked = true;
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, OType.FullName, "AutoFXProfitsClientTerminal");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// DataSource Main function
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            // Create a client
            _site = new InstanceContext(null, new DataSource());
            _client = new TradeMirrorClient(_site);

            _heartbeatTimer = new Timer(DelaySeconds * 1000);
            _heartbeatTimer.Elapsed += HeartbeatTimerElapsed;
            _heartbeatTimer.AutoReset = true;
            _heartbeatTimer.Enabled = true;

            while (true)
            {
                ReadDataFromSocket();
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 public void FreeResources()
 {
     try
     {
         if (Status == "Connected")
         {
             this.DisconnectFromServer();
         }
         if (_client != null)
         {
             _client.Close();
             _client.Abort();
             _client = null;
         }
     }
     catch (Exception exception)
     {
         Logger.Error(exception, OType.FullName, "FreeResources");
     }
 }