Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Eye-Tracking Classroom
/
Live-Gaze-Analyser
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
97e719e7
authored
Oct 15, 2019
by
Alexander Bazo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix task duration bug
parent
1c8175b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
19 deletions
+27
-19
lib/logic/ImageViewerState.js
+1
-7
lib/rooms/ImageViewerRoom.js
+26
-12
No files found.
lib/logic/ImageViewerState.js
View file @
97e719e7
...
...
@@ -14,14 +14,8 @@ class ImageViewerState extends Schema {
this
.
task
=
null
;
}
setTask
(
task
,
onFinish
)
{
setTask
(
task
)
{
this
.
task
=
task
;
currentCallback
=
onFinish
;
setTimeout
(
this
.
onTaskFinished
,
task
.
duration
);
}
onTaskFinished
()
{
currentCallback
();
}
}
...
...
lib/rooms/ImageViewerRoom.js
View file @
97e719e7
...
...
@@ -2,7 +2,8 @@
const
MAX_GAZE_POINT_AGE
=
4000
,
// Set max update intervall to ~ 30FPS
GAZE_POINT_UPDATE_DELAY
=
1000
/
32
;
GAZE_POINT_UPDATE_DELAY
=
1000
/
32
,
DEFAULT_TASK_DURATION
=
30000
;
const
colyseus
=
require
(
"colyseus"
),
Logger
=
require
(
"../utils/Logger.js"
),
...
...
@@ -16,9 +17,11 @@ var tasks = Task.getTasks(),
availableTasks
,
currentTask
,
currentTaskIndex
,
currentTaskStartTime
,
gazePoints
,
gazeSubscribers
,
lastGazePointUpdate
=
0
;
lastGazePointUpdate
=
0
,
context
;
class
ImageViewerRoom
extends
colyseus
.
Room
{
...
...
@@ -30,6 +33,7 @@ class ImageViewerRoom extends colyseus.Room {
this
.
setState
(
new
ImageViewerState
());
this
.
setSimulationInterval
(
this
.
update
.
bind
(
this
),
ServerConfiguration
.
getUpdateInterval
());
this
.
setTask
();
context
=
this
;
}
createTasks
()
{
...
...
@@ -50,7 +54,8 @@ class ImageViewerRoom extends colyseus.Room {
if
(
message
.
type
===
"gaze"
)
{
if
(
client
.
color
===
undefined
)
{
client
.
color
=
Colors
.
getNextColor
();
Logger
.
log
(
`Assign client color:
${
client
.
color
}
`
,
"ImageViewer Room"
);
Logger
.
log
(
`Assign client color:
${
client
.
color
}
`
,
"ImageViewer Room"
);
}
message
.
data
.
color
=
client
.
color
;
let
point
=
GazePoint
.
fromClientData
(
message
.
data
);
...
...
@@ -104,6 +109,7 @@ class ImageViewerRoom extends colyseus.Room {
}
}
lastGazePointUpdate
=
now
;
this
.
setTask
();
}
updateGazePoints
(
now
)
{
...
...
@@ -118,16 +124,24 @@ class ImageViewerRoom extends colyseus.Room {
}
setTask
()
{
Logger
.
log
(
"Sending current task to state"
,
"ImageViewrRoom"
);
// Cycle through available tasks
currentTaskIndex
+=
1
;
if
(
currentTaskIndex
>=
availableTasks
.
length
)
{
currentTaskIndex
=
0
;
if
(
currentTask
===
undefined
)
{
currentTask
=
availableTasks
[
currentTaskIndex
];
Logger
.
log
(
"Sending current task to state"
,
"ImageViewrRoom"
);
this
.
state
.
setTask
(
currentTask
,
this
.
onTaskFinished
.
bind
(
this
));
currentTaskStartTime
=
Date
.
now
();
return
;
}
if
((
Date
.
now
()
-
currentTaskStartTime
)
>=
DEFAULT_TASK_DURATION
)
{
Logger
.
log
(
"Switching task"
,
"ImageViewrRoom"
);
currentTaskIndex
+=
1
;
if
(
currentTaskIndex
>=
availableTasks
.
length
)
{
currentTaskIndex
=
0
;
}
currentTask
=
availableTasks
[
currentTaskIndex
];
Logger
.
log
(
"Sending current task to state"
,
"ImageViewrRoom"
);
this
.
state
.
setTask
(
currentTask
,
this
.
onTaskFinished
.
bind
(
this
));
currentTaskStartTime
=
Date
.
now
();
}
currentTask
=
availableTasks
[
currentTaskIndex
];
// Send task to state to auto update clients
// Set listener for task change event (is based on task's duration property)
this
.
state
.
setTask
(
currentTask
,
this
.
onTaskFinished
.
bind
(
this
));
}
}
...
...
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