• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Rpc.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CIAPI.Rpc.Client的典型用法代码示例。如果您正苦于以下问题:C# Client类的具体用法?C# Client怎么用?C# Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Client类属于CIAPI.Rpc命名空间,在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetNewsDetailAsync

        public void GetNewsDetailAsync(int storyId, Action<NewsDetailDTO> onSuccess, Action<Exception> onError)
        {
            var client = new Client(RPC_URI);
            client.BeginLogIn(USERNAME, PASSWORD,
                ar =>
                {
                    try
                    {
                        client.EndLogIn(ar);

                        client.BeginGetNewsDetail(storyId.ToString(),
                            ar2 =>
                            {
                                try
                                {
                                    var resp = client.EndGetNewsDetail(ar2);

                                    _client.BeginLogOut(ar3 => _client.EndLogOut(ar3), null);

                                    onSuccess(resp.NewsDetail);
                                }
                                catch (Exception exc)
                                {
                                    onError(exc);
                                }
                            }, null);
                    }
                    catch (Exception exc)
                    {
                        onError(exc);
                    }
                }, null);
        }
开发者ID:fandrei,项目名称:CityIndexNewsWidget,代码行数:33,代码来源:Data.cs


示例2: SetupFixture

 public void SetupFixture()
 {
     _rpcClient = BuildRpcClient();
     _streamingClient = _rpcClient.CreateStreamingClient();
     _CFDmarketId = GetAvailableCFDMarkets(_rpcClient)[0].MarketId;
     _accounts = _rpcClient.AccountInformation.GetClientAndTradingAccount();
 }
开发者ID:Domer79,项目名称:CIAPI.CS,代码行数:7,代码来源:TradesAndOrdersFixture.cs


示例3: DoPolling

        private static void DoPolling()
        {
            var client = new Client(Const.RPC_URI, Const.STREAMING_URI, "Test.{B4E415A7-C453-4867-BDD1-C77ED345777B}");
            try
            {
                client.AppKey = "Test";
                client.StartMetrics();

                client.LogIn(Const.USERNAME, Const.PASSWORD);

                for (int i = 0; i < 10; i++)
                {
                    var accountInfo = client.AccountInformation.GetClientAndTradingAccount();
                    client.TradesAndOrders.ListOpenPositions(accountInfo.CFDAccount.TradingAccountId);
                    Thread.Sleep(1000);
                }

                client.LogOut();
            }
            catch (Exception exc)
            {
                Trace.WriteLine(exc);
            }
            finally
            {
                client.Dispose();
            }
        }
开发者ID:bitpusher,项目名称:SimpleCiapiTest,代码行数:28,代码来源:Repro164.cs


示例4: Main

        static void Main(string[] args)
        {
            try
            {
                var curProcess = Process.GetCurrentProcess();
                var secondsOnStart = curProcess.TotalProcessorTime.TotalSeconds;
                var totalWatch = Stopwatch.StartNew();

                for (int i = 0; i < 20; i++)
                {
                    var client = new Client(Const.RPC_URI, Const.STREAMING_URI, "");
                    var recorder = new Recorder(client);
                    recorder.Start();

                    var loginWatch = Stopwatch.StartNew();
                    client.LogIn(Const.USERNAME, Const.PASSWORD);
                    loginWatch.Stop();

                    var accountInfoWatch = Stopwatch.StartNew();
                    var accountInfo = client.AccountInformation.GetClientAndTradingAccount();
                    accountInfoWatch.Stop();

                    var listSpreadMarketsWatch = Stopwatch.StartNew();
                    var resp = client.SpreadMarkets.ListSpreadMarkets("", "",
                        accountInfo.ClientAccountId, 100, false);
                    listSpreadMarketsWatch.Stop();

                    var logoutWatch = Stopwatch.StartNew();
                    client.LogOut();
                    logoutWatch.Stop();

                    var purgeHandle = client.ShutDown();
                    if (!purgeHandle.WaitOne(60000))
                        throw new ApplicationException();

                    var requests = recorder.GetRequests();
                    if (requests.Count != 4)
                        throw new ApplicationException();

                    AddResult(loginWatch, requests[0], "Login");
                    AddResult(accountInfoWatch, requests[1], "GetClientAndTradingAccount");
                    AddResult(listSpreadMarketsWatch, requests[2], "ListSpreadMarkets");
                    AddResult(logoutWatch, requests[3], "Logout");

                    recorder.Stop();
                    recorder.Dispose();
                    client.Dispose();
                }

                totalWatch.Stop();
                var secondsOnEnd = curProcess.TotalProcessorTime.TotalSeconds;
                Console.WriteLine("CPU time used, seconds: {0} total time: {1}", secondsOnEnd - secondsOnStart, totalWatch.Elapsed.TotalSeconds);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
            }

            Debugger.Break();
        }
开发者ID:fandrei,项目名称:CiapiLatencyTest,代码行数:60,代码来源:Program.cs


示例5: CanChangePassword

        public void CanChangePassword()
        {
            const string NEWPASSWORD = "bingo72652";
            var rpcClient = new Client(Settings.RpcUri,Settings.StreamingUri, AppKey);
            
            //Login with existing credentials
            rpcClient.LogIn(Settings.RpcUserName, Settings.RpcPassword);

            //And change password
            var changePasswordResponse = rpcClient.Authentication.ChangePassword(new ApiChangePasswordRequestDTO()
                                                                                         {
                                                                                             UserName = Settings.RpcUserName,
                                                                                             Password = Settings.RpcPassword,
                                                                                             NewPassword = NEWPASSWORD
                                                                                         });

            Assert.IsTrue(changePasswordResponse.IsPasswordChanged);
            rpcClient.LogOut();

            //Make sure that login existing password fails 
            Assert.Throws<ReliableHttpException>(() => rpcClient.LogIn(Settings.RpcUserName, Settings.RpcUserName));

            //Login with changed password and change back
            rpcClient.LogIn(Settings.RpcUserName, NEWPASSWORD);
            changePasswordResponse = rpcClient.Authentication.ChangePassword(new ApiChangePasswordRequestDTO()
                                                                                         {
                                                                                             UserName = Settings.RpcUserName,
                                                                                             Password = NEWPASSWORD,
                                                                                             NewPassword = Settings.RpcPassword
                                                                                         });

            Assert.IsTrue(changePasswordResponse.IsPasswordChanged);
            rpcClient.LogOut();
            rpcClient.Dispose();
        }
开发者ID:MarcRichomme,项目名称:CIAPI.CS,代码行数:35,代码来源:AccountInformationFixture.cs


示例6: CanMockCiapiServerConversation

        public void CanMockCiapiServerConversation()
        {
            Uri uri = new Uri(NormalizeUrl("/"));
            var rpcClient = new Client(uri, uri, "foobardotnet");

            rpcClient.LogIn("Foo", "Bar");

            Assert.AreEqual("5f28983b-0e0a-4a57-92af-0d07c6fdbc38", rpcClient.Session);

            // get some headlines
            var headlines = rpcClient.News.ListNewsHeadlinesWithSource("dj", "UK", 100);
            Assert.AreEqual(100, headlines.Headlines.Length);

            // get a story id from one of the headlines
            var storyId = headlines.Headlines[0].StoryId;
            Assert.AreEqual(1416482, storyId);

            var storyDetail = rpcClient.News.GetNewsDetail("dj", storyId.ToString());

            Assert.IsTrue(storyDetail.NewsDetail.Story.Contains("By Anita Greil "));

            rpcClient.LogOut();

            rpcClient.Dispose();
        }
开发者ID:Evolutionary-Networking-Designs,项目名称:CassiniDev,代码行数:25,代码来源:CIAPIFixture.cs


示例7: RecordNewDataForCIAPI

        public void RecordNewDataForCIAPI()
        {
            var rpcClient = new Client(new Uri("https://ciapi.cityindex.com/tradingapi"), new Uri("https://push.cityindex.com"), "foobardotnet");

            // start recording requests
            var stream = new MemoryStream();
            var streamRecorder = new StreamRecorder(rpcClient, stream);
            streamRecorder.Start();

            rpcClient.LogIn("secret", "secret");

            var accountInfo = rpcClient.AccountInformation.GetClientAndTradingAccount();
            rpcClient.SpreadMarkets.ListSpreadMarkets("", "", accountInfo.ClientAccountId, 100, false);
            rpcClient.News.ListNewsHeadlinesWithSource("dj", "UK", 10);
            rpcClient.Market.GetMarketInformation(MarketId.ToString());
            rpcClient.PriceHistory.GetPriceBars(MarketId.ToString(), "MINUTE", 1, "20");
            rpcClient.TradesAndOrders.ListOpenPositions(accountInfo.SpreadBettingAccount.TradingAccountId);

            rpcClient.LogOut();

            streamRecorder.Stop();
            stream.Position = 0;

            using (var fileStream = File.Create("recorded_requests.txt"))
            {
                stream.WriteTo(fileStream);
            }
        }
开发者ID:Evolutionary-Networking-Designs,项目名称:CassiniDev,代码行数:28,代码来源:CIAPIFixture.cs


示例8: Client

        public Client(Uri rpcUri, Uri streamingUri, string appKey,IJsonSerializer serializer, IRequestFactory factory)
            : base(serializer, factory)
        {
	#if SILVERLIGHT
	#if WINDOWS_PHONE
	        UserAgent = "CIAPI.PHONE7."+ GetVersionNumber();
	#else
	        UserAgent = "CIAPI.SILVERLIGHT."+ GetVersionNumber();
	#endif
	#else
	        UserAgent = "CIAPI.CS." + GetVersionNumber();
	#endif
        AppKey=appKey;
        _client=this;
        _rootUri = rpcUri;
        _streamingUri = streamingUri;

            this. Authentication = new _Authentication(this);
            this. PriceHistory = new _PriceHistory(this);
            this. News = new _News(this);
            this. CFDMarkets = new _CFDMarkets(this);
            this. SpreadMarkets = new _SpreadMarkets(this);
            this. Market = new _Market(this);
            this. Preference = new _Preference(this);
            this. TradesAndOrders = new _TradesAndOrders(this);
            this. AccountInformation = new _AccountInformation(this);
            this. Messaging = new _Messaging(this);
            this. Watchlist = new _Watchlist(this);
            this. ClientApplication = new _ClientApplication(this);
            this. ExceptionHandling = new _ExceptionHandling(this);
        Log.Debug("Rpc.Client created for " + _rootUri.AbsoluteUri);
        }
开发者ID:MarcRichomme,项目名称:CIAPI.CS,代码行数:32,代码来源:Routes.cs


示例9: CanSendMetrics

        public void CanSendMetrics()
        {

            // set up a listener
            var log = new StringBuilder();
            var writer = new StringWriter(log);
            var listener = new TextWriterTraceListener(writer);
            Trace.Listeners.Add(listener);

            var rpcClient = new Client(Settings.RpcUri, Settings.StreamingUri, "my-test-appkey");
            var metricsRecorder = new MetricsRecorder(rpcClient, new Uri("http://metrics.labs.cityindex.com/LogEvent.ashx"));
            metricsRecorder.Start();

            rpcClient.LogIn(Settings.RpcUserName, Settings.RpcPassword);

            var headlines = rpcClient.News.ListNewsHeadlinesWithSource("dj", "UK", 100);

            foreach (var item in headlines.Headlines)
            {
                rpcClient.News.GetNewsDetail("dj", item.StoryId.ToString());
            }

            new AutoResetEvent(false).WaitOne(10000);

            rpcClient.LogOut();

            metricsRecorder.Stop();
            rpcClient.Dispose();

            Trace.Listeners.Remove(listener);

            var logText = log.ToString();

            Assert.IsTrue(logText.Contains("Latency message complete"), "did not find evidence of metrics being posted");
        }
开发者ID:MarcRichomme,项目名称:CIAPI.CS,代码行数:35,代码来源:AppKeyFixture.cs


示例10: Client

        public Client(Uri rpcUri, Uri streamingUri, string appKey, int backgroundInterval)
            : base(new Serializer(),backgroundInterval)
        {
	#if SILVERLIGHT
	#if WINDOWS_PHONE
	        UserAgent = "CIAPI.PHONE7."+ GetVersionNumber();
	#else
	        UserAgent = "CIAPI.SILVERLIGHT."+ GetVersionNumber();
	#endif
	#else
	        UserAgent = "CIAPI.CS." + GetVersionNumber();
	#endif
        _streamingFactory=new LightStreamerStreamingClientFactory();
        AppKey=appKey;
        _client=this;
        _rootUri = rpcUri;
        _streamingUri = streamingUri;

            this. Authentication = new _Authentication(this);
            this. PriceHistory = new _PriceHistory(this);
            this. News = new _News(this);
            this. CFDMarkets = new _CFDMarkets(this);
            this. SpreadMarkets = new _SpreadMarkets(this);
            this. Market = new _Market(this);
            this. Preference = new _Preference(this);
            this. TradesAndOrders = new _TradesAndOrders(this);
            this. AccountInformation = new _AccountInformation(this);
            this. Messaging = new _Messaging(this);
            this. Watchlist = new _Watchlist(this);
            this. ClientApplication = new _ClientApplication(this);
        Log.Debug("Rpc.Client created for " + _rootUri.AbsoluteUri);
        }
开发者ID:Domer79,项目名称:CIAPI.CS,代码行数:32,代码来源:Routes.cs


示例11: BuildRpcClient

 public Client BuildRpcClient()
 {
     //Thread.Sleep(2000); // to let throttle settle down
     var rpcClient = new Client(Settings.RpcUri, Settings.StreamingUri, AppKey);
     rpcClient.LogIn(Settings.RpcUserName, Settings.RpcPassword);
     return rpcClient;
 }
开发者ID:Domer79,项目名称:CIAPI.CS,代码行数:7,代码来源:RpcFixtureBase.cs


示例12: Issue42

        public void Issue42()
        {

            var rpcClient = new Client(Settings.RpcUri);
            rpcClient.LogIn(Settings.RpcUserName, Settings.RpcPassword);
            var param = new NewStopLimitOrderRequestDTO
                            {
                                OrderId = 0,
                                MarketId = 99498,
                                Currency = null,
                                AutoRollover = false,
                                Direction = "buy",
                                Quantity = 10m,
                                BidPrice = 12094m,
                                OfferPrice = 12098m,
                                AuditId = "20110629-G2PREPROD3-0102794",
                                TradingAccountId = 400002249,
                                IfDone = null,
                                OcoOrder = null,
                                Applicability = null,
                                ExpiryDateTimeUTC = null,
                                Guaranteed = false,
                                TriggerPrice = 0m
                            };
            var response = rpcClient.TradesAndOrders.Order(param);


            rpcClient.LogOut();
        }
开发者ID:psrodriguez,项目名称:CIAPI.CS,代码行数:29,代码来源:FaqIssueResolutionFixture.cs


示例13: BuildUnauthenticatedRpcClient

        protected Client BuildUnauthenticatedRpcClient()
        {
            // WARNING: do not nest or otherwise refactor this method
            // buildUri is looking back 2 stack frames to get the method that called this

            var rpcClient = new Client(BuildUri(), new Uri(_streamingUrl), _apiKey);
            return rpcClient;
        }
开发者ID:bitpusher,项目名称:mocument,代码行数:8,代码来源:CIAPIRecordingFixtureBase.cs


示例14: AutoLogin

 private void AutoLogin()
 {
     if (_ctx == null)
     {
         _ctx = new CIAPI.Rpc.Client(RPC_URI);
         _ctx.LogIn(USERNAME, PASSWORD);
     }
 }
开发者ID:JasonH1,项目名称:cityindex,代码行数:8,代码来源:ModelManagerService.svc.cs


示例15: GetTradingAccountId

 private static int GetTradingAccountId(Client client, int marketId, AccountInformationResponseDTO accountInfo)
 {
     GetMarketInformationResponseDTO marketInfo = client.Market.GetMarketInformation(marketId.ToString());
     bool isCfd = marketInfo.MarketInformation.Name.EndsWith("CFD");
     ApiTradingAccountDTO tradingAccount = isCfd
                                               ? accountInfo.TradingAccounts[0]
                                               : accountInfo.TradingAccounts[1];
     return tradingAccount.TradingAccountId;
 }
开发者ID:psrodriguez,项目名称:CIAPI.CS,代码行数:9,代码来源:Trader.cs


示例16: MetricsRecorder

 /// <summary>
 /// 
 /// </summary>
 /// <param name="client"></param>
 /// <param name="appmetricsUri"></param>
 /// <param name="metricsSession"></param>
 /// <param name="metricsAccessKey"></param>
 public MetricsRecorder(Client client, Uri appmetricsUri, string metricsSession, string metricsAccessKey = null)
     : base(client)
 {
     _metricsSession = metricsSession;
     _metricsAccessKey = metricsAccessKey;
     AppmetricsUri = appmetricsUri;
     
     _metricsTimer = new Timer(ignored => PostMetrics(), null, 1000, 10000);
 }
开发者ID:Domer79,项目名称:CIAPI.CS,代码行数:16,代码来源:MetricsRecorder.cs


示例17: FixtureSetup

 public override void FixtureSetup()
 {
     base.FixtureSetup();
     // hmmmm... only one fixture setup allowed. 
     _rpcClient = BuildRpcClient();
     _streamingClient = _rpcClient.CreateStreamingClient();
     _CFDmarketId = MarketFixture.GetAvailableCFDMarkets(_rpcClient)[0].MarketId;
     _accounts = _rpcClient.AccountInformation.GetClientAndTradingAccount();
 }
开发者ID:Domer79,项目名称:CIAPI.CS,代码行数:9,代码来源:TradesAndOrdersFixture.cs


示例18: MainPage

        public MainPage()
        {
            InitializeComponent();

            Dispatcher.BeginInvoke(() =>
            {
                StartButton.IsEnabled = false;
                StopButton.IsEnabled = false;
            });


            // build an rpc client and log it in.
            rpcClient = new Client(new Uri(RpcServerHost));

            // get a session from the rpc client
            rpcClient.BeginLogIn(UserName, Password, ar =>
                {
                    rpcClient.EndLogIn(ar);

                    Debug.WriteLine("creating client");

                    // build a streaming client.
                    _streamingClient = StreamingClientFactory.CreateStreamingClient(new Uri(PushServerHost), UserName, rpcClient.Session);

                    Debug.WriteLine("connecting client");

                    // note: due to internal changes the 'connect' method
                    // name is a misnomer: no actual network activity is occuring,
                    // only the building of the necessary client connections for 
                    // each of the published data adapters. Actual connection is 
                    // performed on demand for each adapter. This minimizes startup time.

                    // the upside to this is that there is no need to run .Connect in a separate thread.



                    Debug.WriteLine("client connected");


                    // from this point there should be no need to stop, disconnect or dispose of the 
                    // client instance. But if you choose to disconnect a StreamingClient, it should
                    // be disposed and reinstantiated. it is a one use object at this point as this is 
                    // the only usage pattern presented in the sample code.

                    Dispatcher.BeginInvoke(() =>
                        {
                            listBox1.Items.Add("logged in");


                            StartButton.IsEnabled = true;
                            StopButton.IsEnabled = false;
                        });

                }, null);

        }
开发者ID:mikelear,项目名称:CIAPI.CS,代码行数:56,代码来源:MainPage.xaml.cs


示例19: AppKeyIsAppendedToLogonRequest

        public void AppKeyIsAppendedToLogonRequest()
        {
            // look at the log to verify - need to expose interals and provide a means to examine the cache to verify programmatically

            var rpcClient = new Client(Settings.RpcUri, Settings.StreamingUri, "my-test-appkey");
            rpcClient.LogIn(Settings.RpcUserName, Settings.RpcPassword);

            rpcClient.LogOut();
            rpcClient.Dispose();
        }
开发者ID:Domer79,项目名称:CIAPI.CS,代码行数:10,代码来源:AppKeyFixture.cs


示例20: Connect

		public static void Connect() 
		{
			Console.WriteLine ("Connecting to CIAPI");
			_rpcClient = new Client(
				new Uri(ConfigurationManager.AppSettings["Server"]), 
				new Uri(ConfigurationManager.AppSettings["StreamingServer"]), 
				ConfigurationManager.AppSettings["ApiKey"] );
			_rpcClient.LogIn(ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"]);
			_streamingClient = _rpcClient.CreateStreamingClient();
		}
开发者ID:cityindex-attic,项目名称:CIAPI.Samples,代码行数:10,代码来源:Program.cs



注:本文中的CIAPI.Rpc.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CLFramework.PacketWriter类代码示例发布时间:2022-05-24
下一篇:
C# Helpers.FastScanner类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap