Readme.md 1.68 KB
Newer Older
Alexander Bazo committed
1 2
# GazeClient

Alexander Bazo committed
3 4 5
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.
Alexander Bazo committed
6 7 8

## Usage

Alexander Bazo committed
9
**Add the library to your application:**
Alexander Bazo committed
10 11 12 13 14

```
<script type="application/javascript" src="gazeclient.js"></script>
```

15
**Create a client and subscribe to gaze events:**
Alexander Bazo committed
16 17 18

```
var gclient = new GazeClient();
19 20 21
gclient.addEventListener("gazeDataAvailable", function onGazeDataAvailable(event) {
	console.log(event);
});
Alexander Bazo committed
22 23
```

Alexander Bazo committed
24
**Connect to a running gaze data server by providing a valid URL:**
25 26

```
27
gclient.connect("ws://localhost:8001/gaze");
28 29
```

Alexander Bazo committed
30 31 32 33 34 35
### Events

| Event | Type  | Description  | Data |
|---|---|---|---|
| ConnectionOpenedEvent  | connectionclosed  | Invoked when client successfully connected to server.  | - |
| ConnectionClosedEvent  | connectionclosed  | Invoked when client lost connection to server. | - |
Alexander Bazo committed
36
| ConnectionErrorEvent  | erroroccurred  | Invoked when an error occurred during server client communication. | - |
Alexander Bazo committed
37
| DataEvent | dataavailable  | Invoked when new gaze data from eye-tracker is available.  | On-display (x,y) coordinates for both eyes |
Alexander Bazo committed
38 39 40 41 42 43 44

## Build

**Prerequisite**

- node.js

Alexander Bazo committed
45
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/`.