Exemplo n.º 1
0
        static void EndLoggedIn(ReliableAsyncResult result)
        {
            _ctx.EndLogIn(result);
            Console.WriteLine("\r\nLogged in.\r\n");

            BeginListNewsHeadlines("UK", 10);
        }
        private void BuildClients()
        {
            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RPC_URI, "CI-WP7");
            RpcClient.BeginLogIn(USERNAME, PASSWORD, ar =>
            {
                var session = RpcClient.EndLogIn(ar);

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                    StreamingClient = StreamingClientFactory.CreateStreamingClient(STREAM_URI, USERNAME, session.Session);
                    MarketPricesStream = StreamingClient.BuildPricesListener(new[] { MarketId });
                    MarketPricesStream.MessageReceived += OnMarketPricesStreamMessageReceived;
                    OrdersStream = StreamingClient.BuildOrdersListener();
                    OrdersStream.MessageReceived += OnOrdersStreamMessageReceived;

                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting account info"));
                    RpcClient.AccountInformation.BeginGetClientAndTradingAccount(ar2 =>
                    {
                        Account = RpcClient.AccountInformation.EndGetClientAndTradingAccount(ar2);

                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting market info"));
                        RpcClient.Market.BeginGetMarketInformation(MarketId.ToString(), ar3 =>
                        {
                            Market = RpcClient.Market.EndGetMarketInformation(ar3).MarketInformation;
                            Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
                        }, null);
                    }, null);
                });
            }, null);
        }
Exemplo n.º 3
0
        private void LoginButtonClick(object sender, EventArgs e)
        {
            DisableUi();
            _ctx = new CIAPI.Rpc.Client(new Uri(ApiEndpointTextBox.Text),new Uri("http://nostreaminginthisapp.com"),  AppKey);
            _ctx.BeginLogIn(UidTextBox.Text, PwdTextBox.Text, result =>
                {
                    try
                    {

                        _ctx.EndLogIn(result);
                        Invoke(() =>
                        {
                            MainTabControl.Enabled = true;
                            LogOutButton.Enabled = true;
                            LoginButton.Enabled = false;
                            Application.DoEvents();

                        });
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        Cursor = Cursors.Default;
                    }
                }, null);

        }
Exemplo n.º 4
0
        public void FetchNews_async()
        {
            var ctx = new CIAPI.Rpc.Client(RPC_URI);
            var gate = new AutoResetEvent(false);
            ctx.BeginLogIn(USERNAME, PASSWORD, a =>
            {
                ctx.EndLogIn(a);

                ctx.News.BeginListNewsHeadlinesWithSource("dj", "UK", 10, newsResult =>
                {

                    ListNewsHeadlinesResponseDTO news = ctx.News.EndListNewsHeadlinesWithSource(newsResult);

                    //do something with the news

                    ctx.BeginLogOut(result=>
                        {
                            gate.Set();
                        
                        }, null);
                }, null);
            }, null);

            gate.WaitOne();
        }
Exemplo n.º 5
0
 private void LoginButtonClick(object sender, EventArgs e)
 {
     DisableUi();
     _ctx = new CIAPI.Rpc.Client(new Uri(ApiEndpointTextBox.Text), new Uri("http://nostreaminginthisapp.com"), AppKey);
     _ctx.BeginLogIn(UidTextBox.Text, PwdTextBox.Text, result =>
     {
         try
         {
             _ctx.EndLogIn(result);
             Invoke(() =>
             {
                 MainTabControl.Enabled = true;
                 LogOutButton.Enabled   = true;
                 LoginButton.Enabled    = false;
                 Application.DoEvents();
             });
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         finally
         {
             Invoke(() =>
             {
                 Cursor = Cursors.Default;
                 Application.DoEvents();
             });
         }
     }, null);
 }
Exemplo n.º 6
0
        public void InitializeStreamingClient(ReliableAsyncResult ar)
        {
            RpcClient.EndLogIn(ar);
            // need to set up the serializer to be used by stream listeners
            StreamingClientFactory.SetSerializer(new Serializer());

            StreamingClient = StreamingClientFactory.CreateStreamingClient(STREAMING_URI, RpcClient.UserName,
                                                                           RpcClient.Session);
            LogToScreen("rpc client logged in");
        }
 private void BuildClients()
 {
     Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
     RpcClient = new Client(RPC_URI);
     RpcClient.BeginLogIn(USERNAME, PASSWORD, ar =>
     {
         RpcClient.EndLogIn(ar);
         Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
     }, null);
 }
Exemplo n.º 8
0
 private void BuildClients()
 {
     Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
     RpcClient = new Client(new Uri(StaticTestConfig.RpcUrl), new Uri(StaticTestConfig.StreamingUrl), StaticTestConfig.AppKey);
     RpcClient.BeginLogIn(StaticTestConfig.ApiUsername, StaticTestConfig.ApiPassword, ar =>
     {
         RpcClient.EndLogIn(ar);
         Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
     }, null);
 }
Exemplo n.º 9
0
 private void BuildClients()
 {
     Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
     RpcClient = new Client(new Uri(StaticTestConfig.RpcUrl), new Uri(StaticTestConfig.StreamingUrl), StaticTestConfig.AppKey);
     RpcClient.BeginLogIn(StaticTestConfig.ApiUsername, StaticTestConfig.ApiPassword, ar =>
     {
         RpcClient.EndLogIn(ar);
         Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
     }, null);
 }
Exemplo n.º 10
0
        public void FindMarkets()
        {
            var client = new Client(new Uri(ApiUrl));

            LogTextBox.Text = LogTextBox.Text + "Trying to connect.." + Environment.NewLine;

            client.BeginLogIn(UserName, Password,
                              response => Dispatcher.BeginInvoke(new Action(() =>
                              {
                                  client.EndLogIn(response);
                                  LogTextBox.Text = LogTextBox.Text + string.Format("Connected: {0}", !string.IsNullOrEmpty(client.Session)) + Environment.NewLine;
                                  LogTextBox.Text = LogTextBox.Text + string.Format("Call Search Method.")+ Environment.NewLine;

                                  try
                                  {
                                      client.Market.BeginListMarketInformationSearch(
                                          false, // market code not used for search
                                          true, // use market name
                                          false, // iFX markets should always be CFD according to Peter
                                          true,
                                          false,
                                          SearchTextBox.Text,
                                          10,
                                          searchCallBack => Dispatcher.BeginInvoke(() =>
                                                                                       {
                                                                                           {
                                                                                               try
                                                                                               {
                                                                                                   var findedMarkets =
                                                                                                       client.Market.EndListMarketInformationSearch(searchCallBack);

                                                                                                   foreach (var marketInfoDTO in findedMarkets.MarketInformation)
                                                                                                   {

                                                                                                       LogTextBox.Text = LogTextBox.Text + 
                                                                                                           string.Format(marketInfoDTO.MarketId.ToString()) + Environment.NewLine;
                                                                                                   }
                                                                                               }
                                                                                               catch (Exception ex)
                                                                                               {
                                                                                                   LogTextBox.Text = LogTextBox.Text + string.Format("Exception: {0}", ex.Message) + Environment.NewLine;
                                                                                               }

                                                                                           }
                                                                                       }),
                                        null);
                                  }
                                  catch (Exception ex)
                                  {
                                      LogTextBox.Text = LogTextBox.Text + string.Format("Exception: {0}", ex.Message) + Environment.NewLine;
                                  }

                              }), null), null);
        }
Exemplo n.º 11
0
        private void BuildClients()
        {
            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));

            //Hook up a logger for the CIAPI.CS libraries
            LogManager.CreateInnerLogger = (logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
                                           => new SimpleDebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);

            RpcClient = new Client(new Uri(StaticTestConfig.RpcUrl), new Uri(StaticTestConfig.StreamingUrl), AppKey);
            RpcClient.BeginLogIn(StaticTestConfig.ApiUsername, StaticTestConfig.ApiPassword, ar =>
            {
                RpcClient.EndLogIn(ar);
                Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
            }, null);
        }
Exemplo n.º 12
0
        private void BuildClients()
        {
            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));

            //Hook up a logger for the CIAPI.CS libraries
            LogManager.CreateInnerLogger = (logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
                                            => new SimpleDebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);

            RpcClient = new Client(new Uri(StaticTestConfig.RpcUrl), new Uri(StaticTestConfig.StreamingUrl),AppKey);
            RpcClient.BeginLogIn(StaticTestConfig.ApiUsername, StaticTestConfig.ApiPassword, ar =>
            {
                RpcClient.EndLogIn(ar);
                Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
            }, null);
        }
Exemplo n.º 13
0
        public void SubscribeToNewsHeadlineStream()
        {
            //First we need a valid session, obtained from the Rpc client
            var ctx = new CIAPI.Rpc.Client(RPC_URI);
            ctx.BeginLogIn(USERNAME, PASSWORD, a =>
            {
                ctx.EndLogIn(a);

                //Next we create a connection to the streaming api, using the authenticated session
                //You application should only ever have one of these
                var streamingClient = StreamingClientFactory.CreateStreamingClient(STREAMING_URI, USERNAME, ctx.SessionId);
                streamingClient.Connect();

                //And instantiate a listener for news headlines on the appropriate topic
                //You can have multiple listeners on one connection
                //var newsListener = streamingClient.BuildListener<NewsDTO>("NEWS.MOCKHEADLINES.UK");
                var newsListener = streamingClient.BuildNewsHeadlinesListener("NEWS.MOCKHEADLINES.UK");
                newsListener.Start();

                //The MessageRecieved event will be triggered every time a new News headline is available,
                //so attach a handler for that event, and wait until something comes through
                //            var gate = new ManualResetEvent(false);
                NewsDTO recievedNewsHeadline = null;
                newsListener.MessageReceived += (s, e) =>
                {
                    recievedNewsHeadline = e.Data;
                    //Do something with the new News headline data - perhaps update a news ticker?
                    //gate.Set();
                };
                //gate.WaitOne();

                ////Clean up
                ////Stop any listeners
                //newsListener.Stop();
                ////Shut down the connection
                //streamingClient.Disconnect();
                ////Destroy your session
                //ctx.BeginLogOut(result =>
                //{
                //    // gate.Set();

                //}, null);

            }, null);
        }
Exemplo n.º 14
0
        private void BuildClients()
        {
            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RPC_URI, STREAM_URI, "CI-WP7");
            RpcClient.BeginLogIn(USERNAME, PASSWORD, ar =>
            {
                var session = RpcClient.EndLogIn(ar);

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                    StreamingClient    = RpcClient.CreateStreamingClient();
                    MarketPricesStream = StreamingClient.BuildDefaultPricesListener(AccountOperatorId);
                    MarketPricesStream.MessageReceived            += OnMarketPricesStreamMessageReceived;
                    Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
                });
            }, null);
        }
Exemplo n.º 15
0
        private void BuildClients()
        {
            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RPC_URI, STREAM_URI, "CI-WP7");
            RpcClient.BeginLogIn(USERNAME, PASSWORD, ar =>
            {
                var session = RpcClient.EndLogIn(ar);

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                    StreamingClient = RpcClient.CreateStreamingClient();
                    MarketPricesStream = StreamingClient.BuildDefaultPricesListener(AccountOperatorId);
                    MarketPricesStream.MessageReceived += OnMarketPricesStreamMessageReceived;
                    Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
                });
            }, null);
        }
Exemplo n.º 16
0
        private void BuildClients()
        {
            //Hook up a logger for the CIAPI.CS libraries
            LogManager.CreateInnerLogger = (logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
                                           => new SimpleDebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);

            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RpcUri, StreamingUri, "CI-WP7");
            RpcClient.BeginLogIn(UerName, Password, ar =>
            {
                try
                {
                    RpcClient.EndLogIn(ar);
                    //RpcClient.MagicNumberResolver.PreloadMagicNumbersAsync();
                    RpcClient.MagicNumberResolver.PreloadMagicNumbers();
                    ThreadPool.QueueUserWorkItem(_ =>
                    {
                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                        StreamingClient = RpcClient.CreateStreamingClient();
                        PriceListener   = StreamingClient.BuildPricesListener(MarketId);
                        PriceListener.MessageReceived += OnMessageReceived;

                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting account info"));
                        RpcClient.AccountInformation.BeginGetClientAndTradingAccount(ar2 =>
                        {
                            Account = RpcClient.AccountInformation.EndGetClientAndTradingAccount(ar2);

                            Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting market info"));
                            RpcClient.Market.BeginGetMarketInformation(MarketId.ToString(), ar3 =>
                            {
                                Market = RpcClient.Market.EndGetMarketInformation(ar3).MarketInformation;
                                Dispatcher.BeginInvoke(() => Button1.IsEnabled = true);
                            }, null);
                        }, null);
                    });
                }
                catch (Exception ex)
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("exception caught: " + ex));
                }
            }, null);
        }
Exemplo n.º 17
0
        private void BuildClients()
        {
            //Hook up a logger for the CIAPI.CS libraries
            LogManager.CreateInnerLogger = (logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
                         => new SimpleDebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);

            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RpcUri, StreamingUri, "CI-WP7");
            RpcClient.BeginLogIn(UerName, Password, ar =>
            {
                try
                {
                    RpcClient.EndLogIn(ar);
                    //RpcClient.MagicNumberResolver.PreloadMagicNumbersAsync();
                    RpcClient.MagicNumberResolver.PreloadMagicNumbers();
                    ThreadPool.QueueUserWorkItem(_ =>
                    {
                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                        StreamingClient = RpcClient.CreateStreamingClient();
                        PriceListener = StreamingClient.BuildPricesListener(MarketId);
                        PriceListener.MessageReceived += OnMessageReceived;

                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting account info"));
                        RpcClient.AccountInformation.BeginGetClientAndTradingAccount(ar2 =>
                        {
                            Account = RpcClient.AccountInformation.EndGetClientAndTradingAccount(ar2);

                            Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting market info"));
                            RpcClient.Market.BeginGetMarketInformation(MarketId.ToString(), ar3 =>
                            {
                                Market = RpcClient.Market.EndGetMarketInformation(ar3).MarketInformation;
                                Dispatcher.BeginInvoke(() => Button1.IsEnabled = true);
                            }, null);
                        }, null);
                    });
                }
                catch (Exception ex)
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("exception caught: " + ex));
                }
            }, null);
        }
Exemplo n.º 18
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();


            var authenticatedClient = new CIAPI.Rpc.Client(new Uri(apiUrl));
            authenticatedClient.BeginLogIn(userName, password, (ar) =>
                {
                    authenticatedClient.EndLogIn(ar);

                    var client = new LightstreamerClient(new Uri(streamingUrl), authenticatedClient.UserName, authenticatedClient.Session);

                    client.StatusUpdate += client_StatusUpdate;

                    var listener = client.BuildListener<PriceDTO>(dataAdapter, topic);
                    listener.MessageReceived += listener_MessageReceived;
                }, null);


            
        }
Exemplo n.º 19
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            CIAPIButton.IsEnabled = false;


            // creating a single rpc client for an application is a better
            // approximation of the intended usage.

            client = new Client(new Uri(StaticTestConfig.RpcUrl), new Uri(StaticTestConfig.StreamingUrl), StaticTestConfig.AppKey);
            listBox1.Items.Add("Trying to connect..");


            client.BeginLogIn(StaticTestConfig.ApiUsername, StaticTestConfig.ApiPassword,
                              response => Dispatcher.BeginInvoke(new Action(() =>
            {
                client.EndLogIn(response);

                listBox1.Items.Add(string.Format("Connected: {0}", !string.IsNullOrEmpty(client.Session)));
                CIAPIButton.IsEnabled = true;
            }), null), null);
        }
Exemplo n.º 20
0
        private void BuildClients()
        {
            //Hook up a logger for the CIAPI.CS libraries
            LogManager.CreateInnerLogger = (logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
                                           => new SimpleDebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);

            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RPC_URI, STREAM_URI, "CI-WP7");

            RpcClient.BeginLogIn(USERNAME, PASSWORD, ar =>
            {
                _logger.Info("ending login");
                var session = RpcClient.EndLogIn(ar);

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                    StreamingClient    = RpcClient.CreateStreamingClient();
                    MarketPricesStream = StreamingClient.BuildPricesListener(new[] { MarketId });
                    MarketPricesStream.MessageReceived += OnMarketPricesStreamMessageReceived;
                    OrdersStream = StreamingClient.BuildOrdersListener();
                    OrdersStream.MessageReceived += OnOrdersStreamMessageReceived;

                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting account info"));
                    RpcClient.AccountInformation.BeginGetClientAndTradingAccount(ar2 =>
                    {
                        Account = RpcClient.AccountInformation.EndGetClientAndTradingAccount(ar2);

                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting market info"));
                        RpcClient.Market.BeginGetMarketInformation(MarketId.ToString(), ar3 =>
                        {
                            Market = RpcClient.Market.EndGetMarketInformation(ar3).MarketInformation;
                            Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
                        }, null);
                    }, null);
                });
            }, null);
        }
Exemplo n.º 21
0
        private void BuildClients()
        {
            //Hook up a logger for the CIAPI.CS libraries
            LogManager.CreateInnerLogger = (logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat)
                         => new SimpleDebugAppender(logName, logLevel, showLevel, showDateTime, showLogName, dateTimeFormat);

            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RPC_URI, STREAM_URI, "CI-WP7");
           
            RpcClient.BeginLogIn(USERNAME, PASSWORD, ar =>
            {
                _logger .Info("ending login");
                var session = RpcClient.EndLogIn(ar);

                ThreadPool.QueueUserWorkItem(_ =>
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                    StreamingClient = RpcClient.CreateStreamingClient();
                    MarketPricesStream = StreamingClient.BuildPricesListener(new[] { MarketId });
                    MarketPricesStream.MessageReceived += OnMarketPricesStreamMessageReceived;
                    OrdersStream = StreamingClient.BuildOrdersListener();
                    OrdersStream.MessageReceived += OnOrdersStreamMessageReceived;

                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting account info"));
                    RpcClient.AccountInformation.BeginGetClientAndTradingAccount(ar2 =>
                    {
                        Account = RpcClient.AccountInformation.EndGetClientAndTradingAccount(ar2);

                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting market info"));
                        RpcClient.Market.BeginGetMarketInformation(MarketId.ToString(), ar3 =>
                        {
                            Market = RpcClient.Market.EndGetMarketInformation(ar3).MarketInformation;
                            Dispatcher.BeginInvoke(() => button1.IsEnabled = true);
                        }, null);
                    }, null);
                });
            }, null);
        }
Exemplo n.º 22
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            CIAPIButton.IsEnabled = false;


            // creating a single rpc client for an application is a better
            // approximation of the intended usage.

            client = new Client(new Uri(StaticTestConfig.RpcUrl), new Uri(StaticTestConfig.StreamingUrl), StaticTestConfig.AppKey);
            listBox1.Items.Add("Trying to connect..");


            client.BeginLogIn(StaticTestConfig.ApiUsername, StaticTestConfig.ApiPassword,
                              response => Dispatcher.BeginInvoke(new Action(() =>
                              {
                                  client.EndLogIn(response);

                                  listBox1.Items.Add(string.Format("Connected: {0}", !string.IsNullOrEmpty(client.Session)));
                                  CIAPIButton.IsEnabled = true;
                              }), null), null);

        }
        private void BuildClients()
        {
            Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating rpc client"));
            RpcClient = new Client(RpcUri, StreamingUri, "CI-WP7");
            RpcClient.BeginLogIn(UerName, Password, ar =>
            {
                try
                {
                    RpcClient.EndLogIn(ar);

                    ThreadPool.QueueUserWorkItem(_ =>
                    {
                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("creating listeners"));
                        StreamingClient = RpcClient.CreateStreamingClient();
                        PriceListener = StreamingClient.BuildPricesListener(MarketId);
                        PriceListener.MessageReceived += OnMessageReceived;

                        Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting account info"));
                        RpcClient.AccountInformation.BeginGetClientAndTradingAccount(ar2 =>
                        {
                            Account = RpcClient.AccountInformation.EndGetClientAndTradingAccount(ar2);

                            Dispatcher.BeginInvoke(() => listBox1.Items.Add("getting market info"));
                            RpcClient.Market.BeginGetMarketInformation(MarketId.ToString(), ar3 =>
                            {
                                Market = RpcClient.Market.EndGetMarketInformation(ar3).MarketInformation;
                                Dispatcher.BeginInvoke(() => Button1.IsEnabled = true);
                            }, null);
                        }, null);
                    });
                }
                catch (Exception ex)
                {
                    Dispatcher.BeginInvoke(() => listBox1.Items.Add("exception caught: " + ex));
                }
            }, null);
        }
Exemplo n.º 24
0
        public void FetchNews_async()
        {
            var ctx  = new CIAPI.Rpc.Client(RPC_URI, STREAMING_URI, AppKey);
            var gate = new AutoResetEvent(false);

            ctx.BeginLogIn(USERNAME, PASSWORD, a =>
            {
                ctx.EndLogIn(a);

                ctx.News.BeginListNewsHeadlinesWithSource("dj", "UK", 10, newsResult =>
                {
                    ListNewsHeadlinesResponseDTO news = ctx.News.EndListNewsHeadlinesWithSource(newsResult);

                    //do something with the news

                    ctx.BeginLogOut(result =>
                    {
                        gate.Set();
                    }, null);
                }, null);
            }, null);

            gate.WaitOne();
        }