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
Yoann HOUPERT
hublot
Commits
b68617d7
Commit
b68617d7
authored
Oct 19, 2017
by
Yoann HOUPERT
Browse files
allow bot to clear connection if disconnected
parent
8f4d0dc9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
5 deletions
+43
-5
client/controller/controller.js
client/controller/controller.js
+3
-0
client/robot/robot.js
client/robot/robot.js
+36
-4
client/robot/robot.test.js
client/robot/robot.test.js
+4
-1
No files found.
client/controller/controller.js
View file @
b68617d7
...
...
@@ -30,9 +30,12 @@ const room = arguments[0];
robotController
=
{
$scope
:
angular
.
element
(
document
.
body
).
scope
().
$root
,
$injector
:
angular
.
element
(
document
.
body
).
injector
(),
chatService
:
angular
.
element
(
document
.
body
).
injector
().
get
(
'
chat
'
),
getWebRTCAdapter
:
()
=>
robotController
.
$injector
.
get
(
'
easyRTCAdapter
'
),
getMyId
:
()
=>
{
return
easyrtc
.
myEasyrtcid
;
},
...
...
client/robot/robot.js
View file @
b68617d7
...
...
@@ -35,6 +35,7 @@ robot = {
recordedParticipantsWS
:
{},
participantsMediaRecorders
:
{},
isDisconnected
:
false
,
intervalList
:
[],
processAudio
(
stream
,
callback
,
interval
)
{
const
mediaRecorder
=
new
MediaRecorder
(
stream
);
...
...
@@ -130,6 +131,30 @@ robot = {
}
},
clearConnection
()
{
for
(
let
i
=
0
;
i
<
robot
.
intervalList
.
length
;
i
++
)
{
clearInterval
(
robot
.
intervalList
[
i
]);
}
const
keyMap
=
Object
.
keys
(
robot
.
recordedParticipantsWS
);
if
(
!
keyMap
)
{
for
(
let
i
=
0
;
i
<
keyMap
.
length
;
i
++
)
{
if
(
!
keyMap
[
i
])
{
robot
.
stopRecordParticipant
(
keyMap
[
i
]);
}
}
}
},
reconnect
()
{
robotController
.
getWebRTCAdapter
().
addDisconnectCallback
(()
=>
{
function
restart
()
{
robot
.
clearConnection
();
robot
.
onConnection
();
}
restart
();
});
},
start
:
()
=>
{
robotLib
.
stt
=
robotLib
.
stt
(
config
);
robotLib
.
reco
=
robotLib
.
reco
(
config
);
...
...
@@ -144,6 +169,11 @@ robot = {
robot
.
checkDisconnect
();
};
robot
.
reconnect
();
robot
.
onConnection
();
},
onConnection
:
()
=>
{
const
recoStartRetry
=
()
=>
{
if
(
robotLib
.
reco
.
start
(
room
))
{
clearInterval
(
robot
.
recoInterval
);
...
...
@@ -151,11 +181,12 @@ robot = {
};
robot
.
recoInterval
=
setInterval
(
recoStartRetry
,
8000
);
setInterval
(
()
=>
robotLib
.
reco
.
getOnlineReco
(
room
)
robot
.
intervalList
.
push
(
robot
.
recoInterval
);
robot
.
intervalList
.
push
(
setInterval
(()
=>
robotLib
.
reco
.
getOnlineReco
(
room
)
.
then
(
robot
.
processReco
)
.
catch
(
console
.
error
),
8000
);
8000
)
)
;
// Record current participants already present in the room
// (except the robot itself)
...
...
@@ -166,11 +197,12 @@ robot = {
}
// Wait 5 minute before leaving a room if alone
setInterval
(
robot
.
checkDisconnect
,
300000
);
robot
.
intervalList
.
push
(
setInterval
(
robot
.
checkDisconnect
,
300000
)
)
;
},
stop
:
()
=>
{
robot
.
isDisconnected
=
true
;
robot
.
clearConnection
();
robotController
.
disconnect
();
}
};
...
...
client/robot/robot.test.js
View file @
b68617d7
...
...
@@ -81,7 +81,10 @@ describe('client/robot', () => {
getRemoteStream
:
id
=>
({
type
:
'
RemoteStream
'
,
id
}),
disconnect
:
()
=>
{
global
.
isDisconnected
=
true
;
}
},
getWebRTCAdapter
:
()
=>
({
addDisconnectCallback
:
()
=>
{}
})
};
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