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
617a5c02
Commit
617a5c02
authored
Oct 13, 2017
by
Yoann HOUPERT
Browse files
clean code disconenct robot
parent
e11eb7fd
Pipeline
#3644
failed with stage
in 34 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
client/controller/controller.js
client/controller/controller.js
+1
-1
client/controller/controller.test.js
client/controller/controller.test.js
+2
-2
client/robot/robot.js
client/robot/robot.js
+4
-4
client/robot/robot.test.js
client/robot/robot.test.js
+9
-9
No files found.
client/controller/controller.js
View file @
617a5c02
...
...
@@ -21,7 +21,7 @@ robotController = {
return
easyrtc
.
getRemoteStream
(
participant
);
},
getParticipants
:
()
=>
{
get
Remote
Participants
:
()
=>
{
const
participants
=
easyrtc
.
getRoomOccupantsAsArray
(
room
);
const
res
=
[];
for
(
let
i
=
0
;
i
<
participants
.
length
;
i
++
)
{
...
...
client/controller/controller.test.js
View file @
617a5c02
...
...
@@ -59,14 +59,14 @@ describe('client/controller', () => {
});
test
(
'
should return the correct participants
'
,
()
=>
{
const
participants
=
global
.
robotController
.
getParticipants
();
const
participants
=
global
.
robotController
.
get
Remote
Participants
();
expect
(
participants
).
toEqual
(
expect
.
arrayContaining
([
'
p1
'
,
'
p2
'
,
'
p3
'
]));
expect
(
participants
).
toHaveLength
(
3
);
});
test
(
'
should not return participants without stream
'
,
()
=>
{
global
.
easyrtc
=
easyRTCMock
([
'
p1
'
,
'
p2
'
,
'
p3
'
],
[
'
nostream
'
]);
const
participants
=
global
.
robotController
.
getParticipants
();
const
participants
=
global
.
robotController
.
get
Remote
Participants
();
expect
(
participants
).
not
.
toEqual
(
expect
.
arrayContaining
([
'
nostream
'
]));
expect
(
participants
).
toHaveLength
(
3
);
...
...
client/robot/robot.js
View file @
617a5c02
...
...
@@ -90,7 +90,7 @@ robot = {
},
checkDisconnect
()
{
if
(
robotController
.
getParticipants
().
length
===
1
)
{
if
(
robotController
.
get
Remote
Participants
().
length
===
0
)
{
robot
.
stop
();
}
},
...
...
@@ -125,14 +125,14 @@ robot = {
// Record current participants already present in the room
// (except the robot itself)
for
(
const
participantId
of
robotController
.
getParticipants
())
{
for
(
const
participantId
of
robotController
.
get
Remote
Participants
())
{
if
(
participantId
!==
robotController
.
getMyId
())
{
robot
.
recordParticipant
(
participantId
);
}
}
// Wait 5 minute before leaving a room if alone
set
Timeout
(
robot
.
checkDisconnect
,
300000
);
set
Interval
(
robot
.
checkDisconnect
,
300000
);
},
stop
:
()
=>
{
...
...
client/robot/robot.test.js
View file @
617a5c02
...
...
@@ -41,10 +41,10 @@ describe('client/robot', () => {
};
global
.
MediaRecorder
.
instances
=
{};
global
.
_set
Timeout
Calls
=
[];
global
.
_set
Interval
Calls
=
[];
global
.
set
Timeout
=
function
(
f
,
timeout
)
{
global
.
_set
Timeout
Calls
.
push
([
f
,
timeout
]);
global
.
set
Interval
=
function
(
f
,
timeout
)
{
global
.
_set
Interval
Calls
.
push
([
f
,
timeout
]);
};
global
.
isDisconnected
=
false
;
...
...
@@ -53,8 +53,8 @@ describe('client/robot', () => {
load
:
()
=>
{}
},
getMyId
:
()
=>
'
robotId
'
,
getParticipants
:
()
=>
[
global
.
robotController
.
getMyId
()
,
get
Remote
Participants
:
()
=>
[
'
someid0
'
,
'
someid1
'
,
'
someid2
'
],
...
...
@@ -82,9 +82,9 @@ describe('client/robot', () => {
expect
(
global
.
robot
).
toBeDefined
();
});
test
(
'
should set a
timeout
for disconnection
'
,
()
=>
{
test
(
'
should set a
interval
for disconnection
'
,
()
=>
{
global
.
robot
.
start
();
expect
(
global
.
_setTimeoutCalls
).
toEqual
(
expect
.
arrayContaining
([[
global
.
robot
.
checkDisconnect
,
300000
]])
)
;
expect
.
arrayContaining
([[
global
.
robot
.
checkDisconnect
,
300000
]]);
});
test
(
'
should return a started mediaRecorder on `processAudio`
'
,
()
=>
{
...
...
@@ -155,8 +155,8 @@ describe('client/robot', () => {
});
test
(
'
should disconnected without user
'
,
()
=>
{
global
.
robotController
.
getParticipants
=
function
()
{
// Redefine getParticipants for o
ne
user
return
[
global
.
robotController
.
getMyId
()
];
global
.
robotController
.
get
Remote
Participants
=
function
()
{
// Redefine get
Remote
Participants for
n
o user
return
[];
};
global
.
robot
.
start
();
...
...
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