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);
        }
Example #2
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);
        }
Example #3
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);
        }
        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);
        }