0

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?

jfisch
  • 1
  • 1

1 Answers1

0

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();
    ...
};
Community
  • 1
  • 1
ShelbyZ
  • 1,494
  • 1
  • 14
  • 32
  • Thanks for your answer! It seems like IE isn't executing async callbacks at all in onbeforeunload (in contrast to Chrome, I've tested this with an ajax call in onbeforeunload) even with your workaround. I think because the Skype Web SDK is relying on this async callbacks to stop/leave a conversation it's not possible to stop the conversation in the casual way. Do you know any way to force the SDK to stop the conversation without internally waiting on something? Sadly the server side takes way too long to realize that the client's gone (you're right, it checks this). – jfisch Dec 14 '16 at 09:31
  • I added a more robust onbeforeunload option as it seems just returning a string message is not relevant for all cases. I also added the option to call signOut on the signInManager as that would also trigger a cleanup. Without some form of delay in onbeforeunload you are stuck hoping that the call finished before unloading. – ShelbyZ Dec 14 '16 at 14:46
  • In my testing IE didn't execute anything while the Leave-Or-Stay-Box has been displayed. I also tested executing AJAX requests. It turned out that a request is sent (also without the Leave-Or-Stay-Box) but the callbacks never get executed. Do you think it would be possible to do a simple AJAX request to UCWA to delete the conversation? – jfisch Dec 15 '16 at 08:34
  • It would be possible, but the problem being you would most likely not have access to the URL you would need to execute a DELETE on from the Skype Web SDK. – ShelbyZ Dec 15 '16 at 16:00
  • Yes, would probably be a cross ref domain request... So it has to be within the sdk.js of the Skype Web SDK that is loaded from that server, right? – jfisch Dec 15 '16 at 16:49
  • The Skype Web SDK is a layer on top of URLs returned by UCWA and it does not expose a good way to get direct access. If you had a network trace you would see requests like /ucwa/v1/applications/GUID and if you had that URL you could issue a DELETE request and that would trigger the cleanup on the server side. The signInManager's signOut(...) method should be doing exactly this action. – ShelbyZ Dec 15 '16 at 17:27