Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LINAGORA
L
LGS
Labs
hublot
Commits
a5012f1f
Commit
a5012f1f
authored
Oct 31, 2017
by
Yoann HOUPERT
Browse files
Merge branch 'issue-36' into 'master'
Client notifies server when ending See merge request !41
parents
09f1992b
9d42dcde
Pipeline
#4886
passed with stage
in 40 seconds
Changes
3
Pipelines
5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
4 deletions
+62
-4
client/robot/robot.js
client/robot/robot.js
+6
-0
lib/controller.js
lib/controller.js
+23
-0
lib/controller.test.js
lib/controller.test.js
+33
-4
No files found.
client/robot/robot.js
View file @
a5012f1f
...
...
@@ -203,6 +203,12 @@ robot = {
robot
.
isDisconnected
=
true
;
robotController
.
disconnect
();
robot
.
clearConnection
();
robot
.
notifyEndToServer
();
},
// This function will be overridden by a server callback
notifyEndToServer
:
()
=>
{
console
.
error
(
'
`notifyEndToServer`: Server has not registered a callback!
'
);
}
};
...
...
lib/controller.js
View file @
a5012f1f
...
...
@@ -35,6 +35,29 @@ const create = (runner, modules, config) => {
config
.
visio
.
url
,
room
,
config
.
client
);
// Add callback for client to inform when it leaves the room
controller
.
registry
[
room
]
.
timeouts
(
'
script
'
,
2147483000
)
// We need big timeouts here (here ~600h)
.
executeAsync
(
done
=>
{
// Note that this code is executed in the selenium-driven browser
/* eslint-disable no-undef */
robot
.
notifyEndToServer
=
()
=>
{
done
(
'
finished
'
);
console
.
log
(
'
notified server I finished
'
);
};
/* eslint-enable */
}).
then
(()
=>
{
delete
controller
.
registry
[
room
];
console
.
log
(
'
client for room
'
,
room
,
'
finished
'
);
}).
catch
(
err
=>
{
console
.
log
(
'
got error
'
,
err
);
// Careful, there is a bug here with chomedriver; if we open the
// console of the selenium-driven browser, an exception is thrown.
// This means that this part may break in dev (but not in prod).
// See issue #65 for more details.
});
return
controller
.
registry
[
room
];
},
...
...
lib/controller.test.js
View file @
a5012f1f
...
...
@@ -25,11 +25,27 @@ const {create} = require('./controller.js');
// Here are some needed mocks
const
functionRunnerMock
=
{
callbacks
:
[],
catch
()
{
return
functionRunnerMock
;
},
end
()
{
return
functionRunnerMock
;
},
execute
()
{
return
{
end
()
{
}
};
return
functionRunnerMock
;
},
executeAsync
()
{
return
functionRunnerMock
;
},
timeouts
()
{
return
functionRunnerMock
;
},
then
(
callback
)
{
functionRunnerMock
.
callbacks
.
push
(
callback
);
return
functionRunnerMock
;
}
};
...
...
@@ -49,6 +65,7 @@ let controller;
describe
(
'
controller
'
,
()
=>
{
beforeEach
(()
=>
{
controller
=
create
(
runnerMock
,
[],
configMock
);
functionRunnerMock
.
callbacks
=
[];
});
test
(
'
should allow to create a client to a new room
'
,
()
=>
{
...
...
@@ -84,4 +101,16 @@ describe('controller', () => {
controller
.
forceDisconnect
(
'
test1
'
);
expect
(
controller
.
registry
).
toHaveProperty
(
'
test2
'
,
client2
);
});
test
(
'
should have registered a finish callback to the client
'
,
()
=>
{
controller
.
client
(
'
test
'
);
expect
(
functionRunnerMock
.
callbacks
.
length
).
toBe
(
1
);
});
test
(
'
should clean registry on client finish callback
'
,
()
=>
{
controller
.
client
(
'
test
'
);
expect
(
controller
.
registry
).
toHaveProperty
(
'
test
'
);
functionRunnerMock
.
callbacks
[
0
]();
expect
(
controller
.
registry
).
not
.
toHaveProperty
(
'
test
'
);
});
});
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