Beispiel #1
0
        //
        // Excel calls this. It's an entry point. It passes us a callback
        // structure which we save for later.
        //
        int IRtdServer.ServerStart(IRtdUpdateEvent callback)
        {
            _callback = callback;

            // We will throttle out updates so that Excel can keep up.
            // It is also important to invoke the Excel callback notify
            // function from the COM thread. System.Windows.Threading'
            // DispatcherTimer will use COM thread's message pump.
            _timer          = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(33);  // Make this fast
            _timer.Tick    += TimerElapsed;
            _timer.Start();

            // moved from constructor as this is a blocking call when network is down
            Task.Run(() => {
                _socket = new GdaxWebSocketClient(new Uri("wss://ws-feed.gdax.com"));
                _socket.Start();
                _socket.MessageReceived += OnWebSocketMessageReceived;
            });
            return(1);
        }
        //
        // Excel calls this. It's an entry point. It passes us a callback
        // structure which we save for later.
        //
        int IRtdServer.ServerStart(IRtdUpdateEvent callback)
        {
            _callback = callback;

            //
            // We will throttle out updates so that Excel can keep up.
            // It is also important to invoke the Excel callback notify
            // function from the COM thread. System.Windows.Threading'
            // DispatcherTimer will use COM thread's message pump.
            //
            _timer          = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(33);  // Make this fast
            _timer.Tick    += TimerElapsed;
            _timer.Start();

            _socket.Start();
            _socket.MessageReceived += OnWebSocketMessageReceived;

            //_binanceViewModel.Init();

            return(1);
        }