gazeclient.js.map 8.28 KB
Newer Older
1
{"version":3,"file":"gazeclient.js","sources":["../lib/utils/Observable.js","../lib/com/Events.js","../lib/data/GazeData.js","../lib/com/WebSocketClient.js","../lib/index.js"],"sourcesContent":["class Observable {\r\n\r\n  constructor() {\r\n    this.listeners = {};\r\n  }\r\n\r\n  addEventListener(type, callback) {\r\n    if (this.listeners[type] === undefined) {\r\n      this.listeners[type] = [];\r\n    }\r\n    this.listeners[type].push(callback);\r\n  }\r\n\r\n  notifyAll(event) {\r\n    let listeners = this.listeners[event.type];\r\n    if (listeners) {\r\n      for (let i = 0; i < listeners.length; i++) {\r\n        listeners[i](event);\r\n      }\r\n    }\r\n  }\r\n\r\n}\r\n\r\nexport default Observable;","class Event {\r\n\r\n  constructor(type, data) {\r\n    this.type = type;\r\n    this.data = data;\r\n  }\r\n\r\n}\r\n\r\nclass DataEvent extends Event {\r\n  constructor(data) {\r\n    super(\"dataavailable\", data);\r\n  }\r\n}\r\n\r\nclass ConnectionOpenedEvent extends Event {\r\n  constructor() {\r\n    super(\"connectionopened\");\r\n  }\r\n}\r\n\r\nclass ConnectionClosedEvent extends Event {\r\n  constructor() {\r\n    super(\"connectionclosed\");\r\n  }\r\n}\r\n\r\nclass ConnectionErrorEvent extends Event {\r\n  constructor() {\r\n    super(\"erroroccurred\");\r\n  }\r\n}\r\n\r\nexport {DataEvent, ConnectionOpenedEvent, ConnectionClosedEvent, ConnectionErrorEvent};","const DATA_SEPERATOR = \";\";\r\n\r\nclass GazeData {\r\n  constructor(leftEyeX, leftEyeY, rightEyeX, rightEyeY, trackerTimeStamp,\r\n    systemTimeStamp) {\r\n    this.leftEyeX = leftEyeX;\r\n    this.leftEyeY = leftEyeY;\r\n    this.rightEyeX = rightEyeX;\r\n    this.rightEyeY = rightEyeY;\r\n    this.trackerTimeStamp = trackerTimeStamp;\r\n    this.systemTimeStamp = systemTimeStamp;\r\n  }\r\n\r\n  static fromDataString(dataString) {\r\n    let dataValues = dataString.split(DATA_SEPERATOR);\r\n    return new GazeData(dataValues[0], dataValues[1], dataValues[2],\r\n      dataValues[3], dataValues[4], dataValues[5]);\r\n  }\r\n}\r\n\r\nexport default GazeData;","import Observable from \"../utils/Observable.js\";\r\nimport { ConnectionOpenedEvent, ConnectionClosedEvent, ConnectionErrorEvent,\r\n  DataEvent } from \"./Events.js\";\r\nimport GazeData from \"../data/GazeData.js\";\r\n\r\nclass WebSocketClient extends Observable {\r\n\r\n  constructor() {\r\n    super();\r\n  }\r\n\r\n  connect(url) {\r\n    this.ws = new WebSocket(url);\r\n    this.ws.onopen = onOpen.bind(this);\r\n    this.ws.onclose = onClose.bind(this);\r\n    this.ws.onerror = onError.bind(this);\r\n    this.ws.onmessage = onMessage.bind(this);\r\n  }\r\n\r\n}\r\n\r\nfunction onOpen() {\r\n  let connectionEvent = new ConnectionOpenedEvent();\r\n  this.notifyAll(connectionEvent);\r\n}\r\n\r\nfunction onClose() {\r\n  let connectionEvent = new ConnectionClosedEvent();\r\n  this.notifyAll(connectionEvent);\r\n}\r\n\r\nfunction onError() {\r\n  let connectionEvent = new ConnectionErrorEvent();\r\n  this.notifyAll(connectionEvent);\r\n}\r\n\r\nfunction onMessage(event) {\r\n  let data = GazeData.fromDataString(event.data),\r\n    dataEvent = new DataEvent(data);\r\n  this.notifyAll(dataEvent);\r\n}\r\n\r\nexport default WebSocketClient;","import Observable from \"./utils/Observable.js\";\r\nimport WebSocketClient from \"./com/WebSocketClient.js\";\r\n\r\nclass GazeClient extends Observable {\r\n\r\n  constructor() {\r\n    super();\r\n  }\r\n\r\n  connect(url) {\r\n    this.url = url;\r\n    this.client = new WebSocketClient();\r\n    this.client.addEventListener(\"connectionopened\", this.onConnected.bind(this));\r\n    this.client.addEventListener(\"connectionclosed\", this.onDisconnected.bind(this));\r\n    this.client.addEventListener(\"erroroccurred\", this.onDisconnected.bind(this));\r\n    this.client.addEventListener(\"dataavailable\", this.onDataAvailable\r\n      .bind(this));\r\n    this.client.connect(url);\r\n  }\r\n\r\n  onConnected(event) {\r\n    this.notifyAll(event);\r\n  }\r\n\r\n  onDisconnected(event) {\r\n    this.notifyAll(event);\r\n  }\r\n\r\n  onError(event) {\r\n    this.notifyAll(event);\r\n  }\r\n\r\n  onDataAvailable(event) {\r\n    this.notifyAll(event);\r\n  }\r\n\r\n}\r\n\r\nwindow.GazeClient = GazeClient;"],"names":[],"mappings":";;;;EAAA,MAAM,UAAU,CAAC;;EAEjB,EAAE,WAAW,GAAG;EAChB,IAAI,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;EACxB,GAAG;;EAEH,EAAE,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE;EACnC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE;EAC5C,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;EAChC,KAAK;EACL,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;EACxC,GAAG;;EAEH,EAAE,SAAS,CAAC,KAAK,EAAE;EACnB,IAAI,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;EAC/C,IAAI,IAAI,SAAS,EAAE;EACnB,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;EACjD,QAAQ,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;EAC5B,OAAO;EACP,KAAK;EACL,GAAG;;EAEH,CAAC;;ECtBD,MAAM,KAAK,CAAC;;EAEZ,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE;EAC1B,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;EACrB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;EACrB,GAAG;;EAEH,CAAC;;EAED,MAAM,SAAS,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