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
3d51d240
Commit
3d51d240
authored
Oct 13, 2017
by
Yoann HOUPERT
Browse files
refactoring disconnect
parent
3fd2e9f5
Pipeline
#3621
passed with stage
in 39 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
42 deletions
+31
-42
client/controller/controller.js
client/controller/controller.js
+4
-8
client/controller/controller.test.js
client/controller/controller.test.js
+20
-10
client/robot/robot.js
client/robot/robot.js
+4
-23
client/robot/robot.test.js
client/robot/robot.test.js
+3
-1
No files found.
client/controller/controller.js
View file @
3d51d240
...
...
@@ -17,23 +17,19 @@ robotController = {
return
easyrtc
.
myEasyrtcid
;
},
getParticipants
:
()
=>
{
return
easyrtc
.
getRoomOccupantsAsArray
(
room
);
},
getRemoteStream
:
participant
=>
{
return
easyrtc
.
getRemoteStream
(
participant
);
},
get
RemoteStream
s
:
()
=>
{
const
participants
=
robotController
.
getParticipants
(
);
const
res
=
{}
;
get
Participant
s
:
()
=>
{
const
participants
=
easyrtc
.
getRoomOccupantsAsArray
(
room
);
const
res
=
[]
;
for
(
let
i
=
0
;
i
<
participants
.
length
;
i
++
)
{
const
participant
=
participants
[
i
];
try
{
const
mediaStream
=
robotController
.
getRemoteStream
(
participant
);
if
(
mediaStream
!==
null
)
{
res
[
participant
]
=
mediaStream
;
res
.
push
(
participant
)
;
}
}
catch
(
err
)
{
console
.
error
(
'
could not get remote stream for %s
'
,
participant
);
...
...
client/controller/controller.test.js
View file @
3d51d240
...
...
@@ -20,9 +20,19 @@ const angular = {
})
};
const
easyRTCMock
=
participants
=>
({
getRoomOccupantsAsArray
:
()
=>
participants
,
getRemoteStream
:
participant
=>
({
origin
:
participant
})
const
easyRTCMock
=
(
participantsWithStream
,
participantsWithoutStream
=
[])
=>
({
getRoomOccupantsAsArray
:
()
=>
participantsWithStream
.
concat
(
participantsWithoutStream
),
getRemoteStream
:
participant
=>
{
// Participant must be in list of participants AND not be in the list
// of participants without stream.
if
(
participantsWithStream
.
indexOf
(
participant
)
!==
-
1
)
{
return
{
origin
:
participant
};
}
return
null
;
}
});
const
document
=
{
...
...
@@ -50,18 +60,18 @@ describe('client/controller', () => {
expect
(
participants
).
toHaveLength
(
3
);
});
test
(
'
should not return participants without stream
'
,
()
=>
{
global
.
easyrtc
=
easyRTCMock
([
'
p1
'
,
'
p2
'
,
'
p3
'
],
[
'
nostream
'
]);
const
participants
=
global
.
robotController
.
getParticipants
();
expect
(
participants
).
not
.
toEqual
(
expect
.
arrayContaining
([
'
nostream
'
]));
});
test
(
'
should return the Streams of the participant
'
,
()
=>
{
const
stream
=
global
.
robotController
.
getRemoteStream
(
'
p2
'
);
expect
(
stream
.
origin
).
toBe
(
'
p2
'
);
});
test
(
'
should return the Streams of all the participants
'
,
()
=>
{
const
streams
=
global
.
robotController
.
getRemoteStreams
();
expect
(
streams
).
toHaveProperty
(
'
p1
'
);
expect
(
streams
).
toHaveProperty
(
'
p2
'
);
expect
(
streams
).
toHaveProperty
(
'
p3
'
);
});
test
(
'
should call listener on push events
'
,
()
=>
{
let
eventFired
=
false
;
...
...
client/robot/robot.js
View file @
3d51d240
...
...
@@ -83,32 +83,13 @@ robot = {
robot
.
getUserStream
(
easyrtcid
);
},
getParticipantNumber
()
{
const
participants
=
robotController
.
getParticipants
();
let
participantsNumber
=
participants
.
length
;
for
(
let
i
=
0
;
i
<
participants
.
length
;
i
++
)
{
const
participant
=
participants
[
i
];
try
{
const
mediaStream
=
robotController
.
getRemoteStream
(
participant
);
if
(
mediaStream
===
null
)
{
participantsNumber
--
;
}
}
catch
(
err
)
{
console
.
error
(
'
could not get remote stream for %s
'
,
participant
);
console
.
error
(
err
);
}
}
return
participantsNumber
;
},
stopRecordParticipant
(
easyrtcid
)
{
robot
.
participantsMediaRecorders
[
easyrtcid
].
stop
();
robot
.
recordedParticipantsWS
[
easyrtcid
].
close
();
},
d
isconnect
Robot
()
{
if
(
robot
.
getParticipantNumber
()
===
1
)
{
checkD
isconnect
()
{
if
(
robot
Controller
.
getParticipantNumber
()
.
length
===
1
)
{
robotController
.
disconnect
();
}
},
...
...
@@ -124,7 +105,7 @@ robot = {
robotController
.
onAttendeeRemove
=
(
e
,
data
)
=>
{
robot
.
stopRecordParticipant
(
data
.
easyrtcid
);
robot
.
d
isconnect
Robot
();
robot
.
checkD
isconnect
();
};
function
recoStartRetry
()
{
...
...
@@ -150,7 +131,7 @@ robot = {
}
// Wait 5 minute before leaving a room if alone
setTimeout
(
robot
.
d
isconnect
Robot
(),
300000
);
setTimeout
(
robot
.
checkD
isconnect
(),
300000
);
}
};
...
...
client/robot/robot.test.js
View file @
3d51d240
...
...
@@ -51,7 +51,9 @@ describe('client/robot', () => {
'
someid1
'
,
'
someid2
'
],
getRemoteStream
:
id
=>
({
type
:
'
RemoteStream
'
,
id
})
getRemoteStream
:
id
=>
({
type
:
'
RemoteStream
'
,
id
}),
getParticipantNumber
:
()
=>
3
,
disconnect
:
()
=>
{}
};
global
.
robotLib
=
{
...
...
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