From f4dd1493ba2cf2c3a5562ff219da38b2520dac02 Mon Sep 17 00:00:00 2001 From: Alexander Bazo Date: Tue, 27 Aug 2019 12:51:21 +0200 Subject: [PATCH] Add gaze client startup --- resources/js/index.js | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/resources/js/index.js b/resources/js/index.js index 1d908d1..211fca4 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -1,22 +1,43 @@ +/* global GazeClient */ + import Logger from "./utils/Logger.js"; import StarGazer from "./game/StarGazer.js"; import GazePoint from "./game/GazePoint.js"; +var gclient = new GazeClient(); + function init() { - Logger.enable(); - document.addEventListener("mousemove", onMouseMove); - StarGazer.init({ - canvas: document.querySelector("canvas"), - fps: 60, - width: 800, - height: 800, - }); + Logger.enable(); + initGazeClient(); + initStarGazer(); +} + +function initGazeClient() { + gclient.connect("ws://localhost:8001/gaze"); + gclient.addEventListener("connectionopened", onConnected); + gclient.addEventListener("dataAvailable", onGazeDataAvailable); + gclient.addEventListener("connectionclosed", onDisconnected); +} + +function initStarGazer() { + StarGazer.init({ + canvas: document.querySelector("canvas"), + fps: 60, + width: 800, + height: 800, + }); +} + +function onConnected(event) { + console.log(event); +} + +function onGazeDataAvailable(event) { + console.log(event); } -function onMouseMove(event) { - StarGazer.onGazeUpdate({ - target: new GazePoint(event.screenX, event.screenY), - }); +function onDisconnected(event) { + console.log(event); } init(); \ No newline at end of file -- libgit2 0.26.0