0
votes

We're building a web application using the Skype Web SDK (https://msdn.microsoft.com/en-us/skype/websdk/docs/skypewebsdk). We use both the audio and the IM capability to get connected to other parties.

Currently we're facing the following problem: If our application is in a conversation with another party (e. g. with a Skype for Business desktop client) and the user leaves or reloads the page, the other party doesn't get notified about the left user.

For audio conversations the result is the following: The other party is still in the call and the only indication of the leaving is that the other party can't hear anything.

For IM conversations the result is the following: If the other party sends an IM in this conversation it gets the notification that the message couldn't be delivered.

We've tried to leave the conversation before the unload of the page using the onbeforeunload event. The callback is executed both in IE 11 and Chrome, but only in Chrome the user actually leaves the conversation (tested with IM conversation since audio/video is not supported in Chrome).

window.onbeforeunload = function() {
    // conversation is the conversation we're currently in
    conversation.leave().then(function () {
        client.conversationsManager.conversations.remove(conversation);
    });
};

Since we rely on the audio capability we're not able to simply switch to Chrome only. Is there any way to ensure that the conversations are cleaned up on page reload/leave in Internet Explorer?

1

1 Answers

0
votes

The problem with what you are trying to do is that the (on)beforeunload event does not wait around for asynchronous methods to complete so you are not guaranteed that leave() will execute nor the inner action to remove the conversation from the conversationsManager. I would suggest an approach similar to the following question - onbeforeunload confirmation screen customization or beforeunload

What you want to do is put the user into a state where the need to interact with a dialog which may (but also not guaranteed) give enough cycles to leave the conversation. In your case it might look something like the following:

window.onbeforeunload = function(e) {
    // track if a conversation is live
    if (_inActiveConversation) {
        // conversation is the conversation we're currently in
        conversation.leave().then(function () {
            client.conversationsManager.conversations.remove(conversation);
        });

        var msg = 'Cleaning up active conversations...';
        e.returnValue = msg;
        return msg;
    }
};

What you should also understand is that eventually the server side will remove that user from the conversation because the application is no longer processing incoming events. So the above is a best effort to clean up resources that will eventually be reclaimed.

You could also try to issuing a signOut request on the signInManager as that should allow the server to clean up resources related to that application on the server side.

window.onbeforeunload = function() {
     ...
    _client.signInManager.signOut();
    ...
};