示例#1
0
 void OnApplicationQuit()
 {
     if (_ws != null && isTracking && _hasInitiatedTracking)
     {
         _ws.Send(GazeIO.Request.toggleTracking);
     }
     if (_tobii != null)
     {
         _tobii.Close();
         _tobii = null;
     }
 }
示例#2
0
 void OnDestroy()
 {
     if (_ws != null)
     {
         _ws.Close();
     }
     if (_tobii != null)
     {
         _tobii.Close();
         _tobii = null;
     }
 }
示例#3
0
    // overrides

    void Awake()
    {
        gazeControls.SetActive(true);

        etudControls.SetActive(!useTobiiSDK);
        tobiiControls.SetActive(useTobiiSDK);

        _log = FindObjectOfType <Log>();

        _smoother = new Smoother <RawPoint>();
        _smoother.saccadeThreshold = 30;
        _smoother.timeWindow       = 150;
        _smoother.dampFixation     = 700;

        if (_simulated)
        {
            _simulator         = FindObjectOfType <GazeSimulator>();
            _simulator.Sample += onSimulatorSample;
            _simulator.State  += onSimulatorState;
            _simulator.Device += onSimulatorDevice;
            _simulator.Initialize();
            return;
        }

        if (useTobiiSDK)
        {
            _tobii          = GetComponent <TobiiClient>();
            _tobii.Error   += onTobiiError;
            _tobii.Ready   += onTobiiReady;
            _tobii.Toggled += onTobiiToggled;
            _tobii.Data    += onTobiiData;

            tobiiEye.value = (int)_tobii.eye;
        }
        else
        {
            _ws         = new WebSocketSharp.WebSocket("ws://localhost:8086/");
            _ws.OnOpen += (sender, e) =>
            {
                print("WS:> Connected");
            };
            _ws.OnClose += (sender, e) =>
            {
                print("WS:> Disconnected");
            };
            _ws.OnError += (sender, e) =>
            {
                print($"WS:> Error {e.Message}");
            };
            _ws.OnMessage += (sender, e) =>
            {
                //print($"WS:> MSG {e.Data}");
                lock (_messages)
                {
                    _messages.Enqueue(e.Data);
                }
            };

            _ws.ConnectAsync();
        }
    }