public IDisposable TestWebsocketsBittrex(bool display = false) { // create a web socket connection to the exchange. Note you can Dispose the socket anytime to shut it down. // the web socket will handle disconnects and attempt to re-connect automatically. IExchangeAPI a = new ExchangeBittrexAPI(); /*using (var socket = b.GetTickersWebSocket((tickers) => * { * Console.WriteLine("{0} tickers, first: {1}", tickers.Count, tickers.First()); * })) * { * Console.WriteLine("Press ENTER to shutdown."); * Console.ReadLine(); * }*/ var socket = a.GetTickersWebSocket((tickers) => { if (display) { Console.WriteLine("BITTREX {0,4} tickers, first: {1}", tickers.Count, tickers.First()); } //HandleTickerUpdate(a, tickers); m_outputQ.Enqueue(new TickerOutput("BITTREX", tickers)); }); return(socket); }
public void TestWebsocketsBittrex() { // create a web socket connection to the exchange. Note you can Dispose the socket anytime to shut it down. // the web socket will handle disconnects and attempt to re-connect automatically. IExchangeAPI b = new ExchangeBittrexAPI(); using (var socket = b.GetTickersWebSocket((tickers) => { Console.WriteLine("{0} tickers, first: {1}", tickers.Count, tickers.First()); })) { Console.WriteLine("Press ENTER to shutdown."); Console.ReadLine(); } }
private static void RunBittrexWebSocket() { var bittrex = new ExchangeBittrexAPI(); IDisposable bitSocket = bittrex.GetTickersWebSocket(freshTickers => { foreach (KeyValuePair <string, ExchangeTicker> kvp in freshTickers) { Console.WriteLine($"market {kvp.Key}, ticker {kvp.Value}"); } }); Console.WriteLine("Press any key to quit."); Console.ReadKey(); bitSocket.Dispose(); }