Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Eye-Tracking Classroom
/
gaze-client.js
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5a1ac23e
authored
Aug 27, 2019
by
Alexander Bazo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix event type in data listener
parent
d05dc0a4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
9 deletions
+9
-9
build/gazeclient.js
+1
-1
build/gazeclient.js.map
+2
-2
build/gazeclient.min.js
+2
-2
demo/gazeclient.min.js
+2
-2
demo/resources/js/index.js
+1
-1
lib/index.js
+1
-1
No files found.
build/gazeclient.js
View file @
5a1ac23e
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
this
.
client
.
addEventListener
(
"connectionopened"
,
this
.
onConnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"connectionopened"
,
this
.
onConnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"connectionclosed"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"connectionclosed"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"erroroccurred"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"erroroccurred"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"data
A
vailable"
,
this
.
onDataAvailable
this
.
client
.
addEventListener
(
"data
a
vailable"
,
this
.
onDataAvailable
.
bind
(
this
));
.
bind
(
this
));
this
.
client
.
connect
(
url
);
this
.
client
.
connect
(
url
);
}
}
...
...
build/gazeclient.js.map
View file @
5a1ac23e
{"version":3,"file":"gazeclient.js","sources":["../lib/utils/Observable.js","../lib/com/Events.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};","import Observable from \"../utils/Observable.js\";\r\nimport { ConnectionOpenedEvent, ConnectionClosedEvent, ConnectionErrorEvent, DataEvent } from \"./Events.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 dataEvent = new DataEvent(event.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,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MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;EACxC,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EAClF,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EACrF,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EAClF,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe;EACtE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EACnB,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;EAC7B,GAAG;;EAEH,EAAE,WAAW,CAAC,KAAK,EAAE;EACrB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,EAAE,cAAc,CAAC,KAAK,EAAE;EACxB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,EAAE,OAAO,CAAC,KAAK,EAAE;EACjB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,EAAE,eAAe,CAAC,KAAK,EAAE;EACzB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,CAAC;;EAED,MAAM,CAAC,UAAU,GAAG,UAAU;;;;"}
{"version":3,"file":"gazeclient.js","sources":["../lib/utils/Observable.js","../lib/com/Events.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};","import Observable from \"../utils/Observable.js\";\r\nimport { ConnectionOpenedEvent, ConnectionClosedEvent, ConnectionErrorEvent, DataEvent } from \"./Events.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 dataEvent = new DataEvent(event.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,I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AI,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EAClF,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EACrF,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EAClF,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe;EACtE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;EACnB,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;EAC7B,GAAG;;EAEH,EAAE,WAAW,CAAC,KAAK,EAAE;EACrB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,EAAE,cAAc,CAAC,KAAK,EAAE;EACxB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,EAAE,OAAO,CAAC,KAAK,EAAE;EACjB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,EAAE,eAAe,CAAC,KAAK,EAAE;EACzB,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;EAC1B,GAAG;;EAEH,CAAC;;EAED,MAAM,CAAC,UAAU,GAAG,UAAU;;;;"}
\ No newline at end of file
\ No newline at end of file
build/gazeclient.min.js
View file @
5a1ac23e
(
function
(){
"use strict"
;
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
)}}}}
class
Event
{
constructor
(
type
,
data
){
this
.
type
=
type
;
this
.
data
=
data
}}
class
DataEvent
extends
Event
{
constructor
(
data
){
super
(
"dataavailable"
,
data
)}}
class
ConnectionOpenedEvent
extends
Event
{
constructor
(){
super
(
"connectionopened"
)}}
class
ConnectionClosedEvent
extends
Event
{
constructor
(){
super
(
"connectionclosed"
)}}
class
ConnectionErrorEvent
extends
Event
{
constructor
(){
super
(
"erroroccurred"
)}}
class
WebSocketClient
extends
Observable
{
constructor
(){
super
()}
connect
(
url
){
this
.
ws
=
new
WebSocket
(
url
);
this
.
ws
.
onopen
=
onOpen
.
bind
(
this
);
this
.
ws
.
onclose
=
onClose
.
bind
(
this
);
this
.
ws
.
onerror
=
onError
.
bind
(
this
);
this
.
ws
.
onmessage
=
onMessage
.
bind
(
this
)}}
function
onOpen
(){
let
connectionEvent
=
new
ConnectionOpenedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onClose
(){
let
connectionEvent
=
new
ConnectionClosedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onError
(){
let
connectionEvent
=
new
ConnectionErrorEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onMessage
(
event
){
let
dataEvent
=
new
DataEvent
(
event
.
data
);
this
.
notifyAll
(
dataEvent
)}
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
})();
(
function
(){
"use strict"
;
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
)}}}}
class
Event
{
constructor
(
type
,
data
){
this
.
type
=
type
;
this
.
data
=
data
}}
class
DataEvent
extends
Event
{
constructor
(
data
){
super
(
"dataavailable"
,
data
)}}
class
ConnectionOpenedEvent
extends
Event
{
constructor
(){
super
(
"connectionopened"
)}}
class
ConnectionClosedEvent
extends
Event
{
constructor
(){
super
(
"connectionclosed"
)}}
class
ConnectionErrorEvent
extends
Event
{
constructor
(){
super
(
"erroroccurred"
)}}
class
WebSocketClient
extends
Observable
{
constructor
(){
super
()}
connect
(
url
){
this
.
ws
=
new
WebSocket
(
url
);
this
.
ws
.
onopen
=
onOpen
.
bind
(
this
);
this
.
ws
.
onclose
=
onClose
.
bind
(
this
);
this
.
ws
.
onerror
=
onError
.
bind
(
this
);
this
.
ws
.
onmessage
=
onMessage
.
bind
(
this
)}}
function
onOpen
(){
let
connectionEvent
=
new
ConnectionOpenedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onClose
(){
let
connectionEvent
=
new
ConnectionClosedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onError
(){
let
connectionEvent
=
new
ConnectionErrorEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onMessage
(
event
){
let
dataEvent
=
new
DataEvent
(
event
.
data
);
this
.
notifyAll
(
dataEvent
)}
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
})();
\ No newline at end of file
\ No newline at end of file
demo/gazeclient.min.js
View file @
5a1ac23e
(
function
(){
"use strict"
;
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
)}}}}
class
Event
{
constructor
(
type
,
data
){
this
.
type
=
type
;
this
.
data
=
data
}}
class
DataEvent
extends
Event
{
constructor
(
data
){
super
(
"dataavailable"
,
data
)}}
class
ConnectionOpenedEvent
extends
Event
{
constructor
(){
super
(
"connectionopened"
)}}
class
ConnectionClosedEvent
extends
Event
{
constructor
(){
super
(
"connectionclosed"
)}}
class
ConnectionErrorEvent
extends
Event
{
constructor
(){
super
(
"erroroccurred"
)}}
class
WebSocketClient
extends
Observable
{
constructor
(){
super
()}
connect
(
url
){
this
.
ws
=
new
WebSocket
(
url
);
this
.
ws
.
onopen
=
onOpen
.
bind
(
this
);
this
.
ws
.
onclose
=
onClose
.
bind
(
this
);
this
.
ws
.
onerror
=
onError
.
bind
(
this
);
this
.
ws
.
onmessage
=
onMessage
.
bind
(
this
)}}
function
onOpen
(){
let
connectionEvent
=
new
ConnectionOpenedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onClose
(){
let
connectionEvent
=
new
ConnectionClosedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onError
(){
let
connectionEvent
=
new
ConnectionErrorEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onMessage
(
event
){
let
dataEvent
=
new
DataEvent
(
event
.
data
);
this
.
notifyAll
(
dataEvent
)}
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
})();
(
function
(){
"use strict"
;
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
)}}}}
class
Event
{
constructor
(
type
,
data
){
this
.
type
=
type
;
this
.
data
=
data
}}
class
DataEvent
extends
Event
{
constructor
(
data
){
super
(
"dataavailable"
,
data
)}}
class
ConnectionOpenedEvent
extends
Event
{
constructor
(){
super
(
"connectionopened"
)}}
class
ConnectionClosedEvent
extends
Event
{
constructor
(){
super
(
"connectionclosed"
)}}
class
ConnectionErrorEvent
extends
Event
{
constructor
(){
super
(
"erroroccurred"
)}}
class
WebSocketClient
extends
Observable
{
constructor
(){
super
()}
connect
(
url
){
this
.
ws
=
new
WebSocket
(
url
);
this
.
ws
.
onopen
=
onOpen
.
bind
(
this
);
this
.
ws
.
onclose
=
onClose
.
bind
(
this
);
this
.
ws
.
onerror
=
onError
.
bind
(
this
);
this
.
ws
.
onmessage
=
onMessage
.
bind
(
this
)}}
function
onOpen
(){
let
connectionEvent
=
new
ConnectionOpenedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onClose
(){
let
connectionEvent
=
new
ConnectionClosedEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onError
(){
let
connectionEvent
=
new
ConnectionErrorEvent
;
this
.
notifyAll
(
connectionEvent
)}
function
onMessage
(
event
){
let
dataEvent
=
new
DataEvent
(
event
.
data
);
this
.
notifyAll
(
dataEvent
)}
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
})();
\ No newline at end of file
\ No newline at end of file
demo/resources/js/index.js
View file @
5a1ac23e
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
var
gclient
=
new
GazeClient
();
var
gclient
=
new
GazeClient
();
gclient
.
connect
(
"ws://localhost:8001/gaze"
);
gclient
.
connect
(
"ws://localhost:8001/gaze"
);
gclient
.
addEventListener
(
"connectionopened"
,
onConnected
);
gclient
.
addEventListener
(
"connectionopened"
,
onConnected
);
gclient
.
addEventListener
(
"data
A
vailable"
,
onGazeDataAvailable
);
gclient
.
addEventListener
(
"data
a
vailable"
,
onGazeDataAvailable
);
gclient
.
addEventListener
(
"connectionclosed"
,
onDisconnected
);
gclient
.
addEventListener
(
"connectionclosed"
,
onDisconnected
);
function
onConnected
(
event
)
{
function
onConnected
(
event
)
{
...
...
lib/index.js
View file @
5a1ac23e
...
@@ -13,7 +13,7 @@ class GazeClient extends Observable {
...
@@ -13,7 +13,7 @@ class GazeClient extends Observable {
this
.
client
.
addEventListener
(
"connectionopened"
,
this
.
onConnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"connectionopened"
,
this
.
onConnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"connectionclosed"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"connectionclosed"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"erroroccurred"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"erroroccurred"
,
this
.
onDisconnected
.
bind
(
this
));
this
.
client
.
addEventListener
(
"data
A
vailable"
,
this
.
onDataAvailable
this
.
client
.
addEventListener
(
"data
a
vailable"
,
this
.
onDataAvailable
.
bind
(
this
));
.
bind
(
this
));
this
.
client
.
connect
(
url
);
this
.
client
.
connect
(
url
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment