예제 #1
0
        /// <summary>
        /// This function handles processing of data and reconnecting. Only run this function from a dedicated background thread
        /// </summary>
        private void ProcessLoop()
        {
            var devices = new[] { Context.Device };

            while (_processInBackground)
            {
                if (_isReconnecting)
                {
                    // do not try to reconnect more than once every 500 ms
                    Thread.Sleep(500);

                    var connected = ConnectionHelper.TryReconnect(_streamEngineInteropWrapper, Context.Device);
                    _isReconnecting = !connected;
                    continue;
                }

                Interop.tobii_wait_for_callbacks(devices); // Important! Without this we will have a busy wait loop.
                var result = ProcessCallback(Context.Device, _stopwatch);
                if (result == tobii_error_t.TOBII_ERROR_CONNECTION_FAILED)
                {
                    UnityEngine.Debug.Log("Reconnecting...");
                    _isReconnecting = true;
                }
            }
        }
예제 #2
0
        public void Tick()
        {
            if (_isReconnecting)
            {
                // do not try to reconnect more than once every 500 ms
                if (Time.unscaledTime - _reconnectionTimestamp < 0.5f)
                {
                    return;
                }

                var connected = ConnectionHelper.TryReconnect(_streamEngineInteropWrapper, Context.Device);
                _isReconnecting = !connected;
                return;
            }

            var result = ProcessCallback(Context.Device, _stopwatch);

            if (result == tobii_error_t.TOBII_ERROR_CONNECTION_FAILED)
            {
                UnityEngine.Debug.Log("Reconnecting...");
                _reconnectionTimestamp = Time.unscaledTime;
                _isReconnecting        = true;
            }
        }