import Observable from "./utils/Observable.js"; import WebSocketClient from "./com/WebSocketClient.js"; class GazeClient extends Observable { constructor() { super(); } connect(url) { this.url = url; this.client = new WebSocketClient(); this.client.addEventListener("connectionopened", this.onConnected.bind(this)); this.client.addEventListener("connectionclosed", this.onDisconnected.bind(this)); this.client.addEventListener("erroroccurred", this.onDisconnected.bind(this)); this.client.addEventListener("dataAvailable", this.onDataAvailable .bind(this)); this.client.connect(url); } onConnected(event) { this.notifyAll(event); } onDisconnected(event) { this.notifyAll(event); } onError(event) { this.notifyAll(event); } onDataAvailable(event) { this.notifyAll(event); } } window.GazeClient = GazeClient;