Пример #1
0
    public override void OnStartClient()
    {
        var setup = FindObjectOfType <GameFlow>().setup;

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

        _simulate = simulate || setup.mode == Setup.Mode.HeadGaze || (Environment.UserName == "csolsp" && Screen.currentResolution.width == 1920);

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

        gazeControls.SetActive(true);

        _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();
    }
Пример #2
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();
        }
    }