From 403ba4e4d293e796b9264c8ceb23e5639d275040 Mon Sep 17 00:00:00 2001 From: Alexander Bazo Date: Thu, 22 Aug 2019 20:29:47 +0200 Subject: [PATCH] Remove old file versions --- lib/Events.js | 0 lib/Observable.js | 37 ------------------------------------- lib/WebSocketClient.js | 42 ------------------------------------------ 3 files changed, 79 deletions(-) delete mode 100644 lib/Events.js delete mode 100644 lib/Observable.js delete mode 100644 lib/WebSocketClient.js diff --git a/lib/Events.js b/lib/Events.js deleted file mode 100644 index e69de29..0000000 --- a/lib/Events.js +++ /dev/null diff --git a/lib/Observable.js b/lib/Observable.js deleted file mode 100644 index fca342e..0000000 --- a/lib/Observable.js +++ /dev/null @@ -1,37 +0,0 @@ -/* eslint-env browser */ - -class Event { - - constructor(type, data) { - this.type = type; - this.data = data; - } - -} - -class Observable { - - constructor() { - this.listeners = {}; - } - - addEventListener(type, callback) { - if (this.listeners[type] === undefined) { - this.listeners[type] = []; - } - this.listeners[type].push(callback); - } - - notifyAll(event) { - let listeners = this.listeners[event.type]; - if (listeners) { - for (let i = 0; i < listeners.length; i++) { - listeners[i](event); - } - } - } - -} - -export default Observable; -export { Event, Observable }; \ No newline at end of file diff --git a/lib/WebSocketClient.js b/lib/WebSocketClient.js deleted file mode 100644 index 446fa37..0000000 --- a/lib/WebSocketClient.js +++ /dev/null @@ -1,42 +0,0 @@ -/* eslint-env browser */ - -import { Observable, Event } from "./Observable.js"; - -class GazeDataEvent extends Event { - constructor(data) { - super("gazeDataAvailable", data); - } -} - -class ConnectionEvent extends Event { - constructor() { - super("connected"); - } -} - -class WebSocketClient extends Observable { - - constructor() { - super(); - } - - connect(url) { - - this.ws = new WebSocket(url); - this.ws.onopen = onOpen.bind(this); - this.ws.onmessage = onMessage.bind(this); - } - -} - -function onOpen() { - let connectionEvent = new ConnectionEvent(); - this.notifyAll(connectionEvent); -} - -function onMessage(event) { - let gazeEvent = new GazeDataEvent(event.data); - this.notifyAll(gazeEvent); -} - -export default WebSocketClient; \ No newline at end of file -- libgit2 0.26.0