Commit b8559772 by Alexander Bazo

Add GazeData object and parsing

parent 5a1ac23e
import Observable from "../utils/Observable.js";
import { ConnectionOpenedEvent, ConnectionClosedEvent, ConnectionErrorEvent, DataEvent } from "./Events.js";
import { ConnectionOpenedEvent, ConnectionClosedEvent, ConnectionErrorEvent,
DataEvent } from "./Events.js";
import GazeData from "../data/GazeData.js";
class WebSocketClient extends Observable {
......@@ -33,7 +35,8 @@ function onError() {
}
function onMessage(event) {
let dataEvent = new DataEvent(event.data);
let data = GazeData.fromDataString(event.data),
dataEvent = new DataEvent(data);
this.notifyAll(dataEvent);
}
......
const DATA_SEPERATOR = ";";
class GazeData {
constructor(leftEyeX, leftEyeY, rightEyeX, rightEyeY, trackerTimeStamp,
systemTimeStamp) {
this.leftEyeX = leftEyeX;
this.leftEyeY = leftEyeY;
this.rightEyeX = rightEyeX;
this.rightEyeY = rightEyeY;
this.trackerTimeStamp = trackerTimeStamp;
this.systemTimeStamp = systemTimeStamp;
}
static fromDataString(dataString) {
let dataValues = dataString.split(DATA_SEPERATOR);
return new GazeData(dataValues[0], dataValues[1], dataValues[2],
dataValues[3], dataValues[4], dataValues[5]);
}
}
export default GazeData;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment