client.stopMediaSessions()
will stop all vline.MediaSessions
for the given vline.Client
, so yes, it will "hang up" a call.
To "hang up" an audio/video session with a specific user (vline.Person
), you can use Person.stopMedia()
.
A vline.MediaSession
can have local and remote vline.MediaStreams
associated with it, so by stopping a vline.MediaSession
you will implicitly stop all vline.MediaStreams
associated with it.
Since client.stopMediaSessions()
is stopping all of the vline.MediaSession
's (and therefore vline.MediaStream
's), you should get both a mediaStream:end
event (from the vline.MediaStream
) and a enterState:closed
event (from the vline.MediaSession
).
For adding and removing <video>
elements and keeping track of them, I'd suggest doing something similar to what the vLine shell example does. It uses the unique MediaStream ID to name the div
that it puts the <video>
element in:
mediaSession.on('mediaSession:addLocalStream mediaSession:addRemoteStream', function(event) {
var stream = event.stream;
// guard against adding a local video stream twice if it is attached to two media sessions
if ($('#' + stream.getId()).length) {
return;
}
$('#video-wrapper').append(elem);
});
// add event handler for remove stream events
mediaSession.on('mediaSession:removeLocalStream mediaSession:removeRemoteStream', function(event) {
$('#' + event.stream.getId()).remove();
});