Beispiel #1
0
        public async Task JsonWebStream_WorksAsync()
        {
            //Arrange
            var session   = new JsonWebSession(StreamingRatesUri, AccessToken);
            var path      = "prices?accountId=" + AccountId + "&instruments=" + Uri.EscapeDataString("EUR_USD,USD_CAD");
            var webStream = new JsonWebStream <RateStreamResponse>(path, session);
            var ticks     = new List <Price>();

            webStream.DataReceived += new JsonWebStream <RateStreamResponse> .DataHandler((s) => ticks.Add(s.tick));

            //Act
            await webStream.BeginReceiveStreamAsync();
        }
Beispiel #2
0
 public void Startup()
 {
     if (_instruments == null)
     {
         throw new Exception("Not initialized");
     }
     else
     {
         var session = new JsonWebSession(_streamingRatesUri, _accessToken);
         var path    = "prices?accountId=" + _accountId + "&instruments=" + Uri.EscapeDataString(_resolvedInstrumentCodes);
         _webStream = new JsonWebStream <RateStreamResponse>(path, session);
         _webStream.DataReceived += OnDataReceived;
         Task.Run(async() => await _webStream.BeginReceiveStreamAsync());
     }
 }