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
403ba4e4
authored
Aug 22, 2019
by
Alexander Bazo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old file versions
parent
51c3f50f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
81 deletions
+0
-81
lib/Events.js
+0
-0
lib/Observable.js
+0
-38
lib/WebSocketClient.js
+0
-43
No files found.
lib/Events.js
deleted
100644 → 0
View file @
51c3f50f
lib/Observable.js
deleted
100644 → 0
View file @
51c3f50f
/* 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
lib/WebSocketClient.js
deleted
100644 → 0
View file @
51c3f50f
/* 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
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