Pages Menu

Posted by on May 25, 2015 in Skype for Business® (Lync®) | 0 comments

Learn Skype Web SDK Day 18 : Terminating a Conversation

Learn Skype Web SDK Day 18 : Terminating a Conversation

This is one post in a series of more than 30, devoted to helping you get up to speed quickly with the new Skype Web SDK. Each lesson comes with source code (in GitHub) and a working demo page so you can see what it does. Check out the full list of posts on the Skype Web SDK page.

View Demo

Be a good Skype for Web API citizan! When your user is done with a conversation, don’t just leave it open – close it! Open conversations are confusing to the other party, consume server resources and local resources and will slow down your application. Besides, it’s one of the easiest things you can do!

If you think back to starting a conversation, you’ll recall that having set up a conversation, we then used the chatService member, and invoked the start() method. You might have noticed that there is a also a stop() method, and assume that this is how you’d end the conversation.

However, there’s a really important distinction to be made here. Understanding this will really help you become a better Skype for Web API developer, especially as you progress to adding voice, video and desktop sharing.

A Skype for Business conversation is defined as two or more users being connected together so that they can communicate. However, within that, there are different ways in which they might be communicating. It might be Instant Messaging (IM), it might be voice, it might be desktop sharing. It might be a combination of those, or all three of them. These different methods of communication are called modalities. A conversation is a container for multiple modalities – a conversation might have one or more modalities, but a modality cannot exist without being in a conversation.

When we call stop() on the chatService, what we’re doing is ending the IM modality, but we’re not ending the conversation. The conversation is still there, just without the modality. Skype for Business is deliberately designed this way – so that you can start a conversation using IM, then add video halfway through, then add desktop sharing, then stop video, then start it again. Each time you don’t have to start a new conversation, it all happens within the same one.

If ending the IM modality whilst keeping the conversation open is what you want to do, then chatService.stop() is the right method for you. But if what you really want to do is end the conversation, there’s another method to use:

[code language=”javascript”]

This will close all modalities in the conversation and correctly terminate the conversation with Skype for Business. If you’re monitoring the list of conversations handled by the conversationsManager then you’ll notice that the conversation gets removed from it’s list using this method (and doesn’t if you just stop the chatService). This is how you should fully terminate conversations.

Remember as well that after a period of inactivity Skype for Business will automatically close down a conversation. Your application should watch for this (check the conversation state: it will change to Disconnected) and respond appropriatly. Otherwise your user may think the conversation is still active and continue to send messages, which won’t go anywhere. Skype for Business won’t magically re-open the conversation if you send more messages.

[code language=”javascript”]

Conversation State:


    Demo Online

    You can try this code out against your own Skype for Business environment by going to the demo page. From here you can also download the code from GitHub if you want to host it locally, or take it and use it in your next project.

    Disclaimer: This is sample code, intended to inform and educate. It is not production-ready and is lacking key components such as error handling. You use it entirely at your own risk. You should fully understand the effects, limitations and risks of the code before executing, and understand the implications of any set-up steps. By using these code examples you are using the Skype Web SDK, so you should read the Skype Software License Terms to which you are agreeing.

    Good to Know

    Post a Reply

    Your email address will not be published. Required fields are marked *

    This site uses cookies to help make this website better. By continuing to use this site we’ll assume you’re OK with that (implied consent).