# GazeClient A Javascript library to subscribe to local gaze data streams in the OTH/UR Eye-Tracking Classroom. Packed and compressed library files can be found in `/build`. GazeClient connects to a running [GazeServer](https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-server.cs) instance on the local machine and publishes gaze data from the currently tracked user. Websockets are used to connect client and server. ## Usage **Add the library to your application:** ``` ``` **Create a client and subscribe to gaze events:** ``` var gclient = new GazeClient(); gclient.addEventListener("gazeDataAvailable", function onGazeDataAvailable(event) { console.log(event); }); ``` **Connect to a running gaze data server by providing a valid URL:** ``` gclient.connect("ws://localhost:8001/gaze"); ``` ### Events | Event | Type | Description | Data | |---|---|---|---| | ConnectionOpenedEvent | connectionclosed | Invoked when client successfully connected to server. | - | | ConnectionClosedEvent | connectionclosed | Invoked when client lost connection to server. | - | | ConnectionErrorEvent | erroroccurred | Invoked when an error occurred during server client communication. | - | | DataEvent | dataavailable | Invoked when new gaze data from eye-tracker is available. | On-display (x,y) coordinates for both eyes | ## Build **Prerequisite** - node.js To build a current version of this library run `npm install` and `npm run build`. The client library is packed with [rollup](https://rollupjs.org/guide/en/), compress with [uglify-es](https://github.com/mishoo/UglifyJS2/tree/harmony) and copied to `build/` and `demo/`.