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
86eded55
Commit
86eded55
authored
Oct 20, 2017
by
Yoann HOUPERT
Browse files
improvement initialisation process
parent
b68617d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
18 deletions
+62
-18
client/robot/robot.js
client/robot/robot.js
+18
-17
client/robot/robot.test.js
client/robot/robot.test.js
+44
-1
No files found.
client/robot/robot.js
View file @
86eded55
...
...
@@ -135,33 +135,33 @@ robot = {
for
(
let
i
=
0
;
i
<
robot
.
intervalList
.
length
;
i
++
)
{
clearInterval
(
robot
.
intervalList
[
i
]);
}
robot
.
intervalList
=
[];
const
keyMap
=
Object
.
keys
(
robot
.
recordedParticipantsWS
);
if
(
!
keyMap
)
{
if
(
keyMap
)
{
for
(
let
i
=
0
;
i
<
keyMap
.
length
;
i
++
)
{
if
(
!
keyMap
[
i
])
{
robot
.
stopRecordParticipant
(
keyMap
[
i
]);
if
(
keyMap
[
i
])
{
try
{
robot
.
stopRecordParticipant
(
keyMap
[
i
]);
}
catch
(
err
)
{
console
.
log
(
'
This user is innactive
'
);
}
}
}
}
},
reconnect
()
{
robotController
.
getWebRTCAdapter
().
addDisconnectCallback
(()
=>
{
function
restart
()
{
robot
.
clearConnection
();
robot
.
onConnection
();
}
restart
();
});
},
start
:
()
=>
{
robotLib
.
stt
=
robotLib
.
stt
(
config
);
robotLib
.
reco
=
robotLib
.
reco
(
config
);
robotLib
.
archive
=
robotLib
.
archive
(
config
);
robotController
.
onAttendeePush
=
(
e
,
data
)
=>
{
robot
.
recordParticipant
(
data
.
easyrtcid
);
if
(
data
.
easyrtcid
===
robotController
.
getMyId
())
{
robot
.
onConnection
();
}
else
{
robot
.
recordParticipant
(
data
.
easyrtcid
);
}
};
robotController
.
onAttendeeRemove
=
(
e
,
data
)
=>
{
...
...
@@ -169,8 +169,9 @@ robot = {
robot
.
checkDisconnect
();
};
robot
.
reconnect
();
robot
.
onConnection
();
robotController
.
getWebRTCAdapter
().
addDisconnectCallback
(()
=>
{
robot
.
clearConnection
();
});
},
onConnection
:
()
=>
{
...
...
@@ -202,8 +203,8 @@ robot = {
stop
:
()
=>
{
robot
.
isDisconnected
=
true
;
robot
.
clearConnection
();
robotController
.
disconnect
();
robot
.
clearConnection
();
}
};
...
...
client/robot/robot.test.js
View file @
86eded55
...
...
@@ -68,6 +68,8 @@ describe('client/robot', () => {
};
global
.
isDisconnected
=
false
;
global
.
isReconnected
=
false
;
global
.
robotController
=
{
external
:
{
load
:
()
=>
{}
...
...
@@ -83,7 +85,9 @@ describe('client/robot', () => {
global
.
isDisconnected
=
true
;
},
getWebRTCAdapter
:
()
=>
({
addDisconnectCallback
:
()
=>
{}
addDisconnectCallback
:
()
=>
{
global
.
isReconnected
=
true
;
}
})
};
...
...
@@ -107,6 +111,7 @@ describe('client/robot', () => {
test
(
'
should set a interval for disconnection
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
expect
.
arrayContaining
([[
global
.
robot
.
checkDisconnect
,
300000
]]);
});
...
...
@@ -136,12 +141,15 @@ describe('client/robot', () => {
test
(
'
should not record itself
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
expect
(
global
.
MediaRecorder
.
instances
)
.
not
.
toHaveProperty
(
global
.
robotController
.
getMyId
());
});
test
(
'
should start transcribing users already present on `start`
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
const
e1
=
{
data
:
'
somedata1
'
};
global
.
MediaRecorder
.
instances
.
someid1
.
ondataavailable
(
e1
);
...
...
@@ -154,6 +162,8 @@ describe('client/robot', () => {
test
(
'
should start transcribing stream on user connection after `start`
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
global
.
robotController
.
onAttendeePush
({},
{
easyrtcid
:
'
testid
'
});
const
e
=
{
data
:
'
somedata
'
};
...
...
@@ -162,8 +172,18 @@ describe('client/robot', () => {
expect
(
sttMock
.
sttDataSent
[
sttMock
.
sttDataSent
.
length
-
1
]).
toBe
(
e
.
data
);
});
test
(
'
should participant be on
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
expect
(
global
.
robot
.
participantsMediaRecorders
.
someid1
.
stopped
).
toBe
(
false
);
expect
(
global
.
robot
.
recordedParticipantsWS
.
someid1
.
status
).
toBe
(
'
open
'
);
});
test
(
'
should stop transcribing stream on user disconnect
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
global
.
robotController
.
onAttendeeRemove
({},
{
easyrtcid
:
'
someid1
'
});
expect
(
global
.
MediaRecorder
.
instances
.
someid1
.
stopped
).
toBeTruthy
();
...
...
@@ -172,23 +192,46 @@ describe('client/robot', () => {
test
(
'
should not disconnected with more than one user
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
global
.
robotController
.
onAttendeeRemove
({},
{
easyrtcid
:
'
someid1
'
});
expect
(
global
.
isDisconnected
).
toBe
(
false
);
});
test
(
'
should trigger when robot is disconnect
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
global
.
robotController
.
getWebRTCAdapter
().
addDisconnectCallback
();
expect
(
global
.
isReconnected
).
toBe
(
true
);
});
test
(
'
should clear the connection
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
global
.
robot
.
clearConnection
();
expect
(
global
.
robot
.
participantsMediaRecorders
.
someid1
.
stopped
).
toBe
(
true
);
expect
(
global
.
robot
.
recordedParticipantsWS
.
someid1
.
status
).
toBe
(
'
closed
'
);
expect
(
global
.
robot
.
intervalList
.
length
).
toBe
(
0
);
});
test
(
'
should disconnected without user
'
,
()
=>
{
global
.
robotController
.
getRemoteParticipants
=
function
()
{
// Redefine getRemoteParticipants for no user
return
[];
};
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
global
.
robotController
.
onAttendeeRemove
({},
{
easyrtcid
:
'
someid1
'
});
expect
(
global
.
isDisconnected
).
toBe
(
true
);
});
test
(
'
should try to reopen a stt ws on error
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
onConnection
();
// Trigger an error
sttMock
.
wsMock
.
status
=
'
error
'
;
...
...
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