Pages Menu
TwitterRssFacebook

Posted by on Jun 8, 2015 in Everything Else | 1 comment

Learn Skype Web SDK Day 28 : Listing Participants in a Conference

Learn Skype Web SDK Day 28 : Listing Participants in a Conference

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

There are two ways to find out about who is in a conference which you have just joined. The first is to get a snapshot of the participant list. This can be useful if you need to quickly build up a picture of who is in the conference, perhaps to build a UI control showing the participants. You can do this by calling:

[code language=”javascript”]
conversation.participants
[/code]

which is a collection of the different participants. For instance, conversation.participants.size() will tell you how many participants are in the conference. You can also iterate through each item in the collection and refer to the .person object of each one.

However, to truly make an interactive display you need to know when people join and leave. There are .added and .removed events which you can subscribe to on the participants object. You should do this before you join the conference (i.e. before you call start on whatever service you’re using). In this example I’m using the chatService:

[code language=”javascript”]
conversation.participants.added(function (participant){
$(“#lblPartitcipants”).append(‘

  • ‘ + “Joined:” + ‘  ‘ + participant.person.displayName() + ‘
  • ‘);
    });

    conversation.participants.removed(function (participant){
    $(“#lblPartitcipants”).append(‘

  • ‘ + “Left:” + ‘  ‘ + participant.person.displayName() + ‘
  • ‘);
    });

    conversation.chatService.start();
    [/code]

    For each participant, you can also subscribe to their state. Valid values are “Disonnected”, “Connecting”, “InLobby”, “Connected”, “Disconnected”, “Disconnecting”. You can also read whether or not they have joined as an anonymous user by using the isAnonymous flag, and their role in the conference. The role object (valid values are “Attendee”, “Leader”) is settable as well as gettable – so you can use this to promote or demote attendees.

    The code sample for today’s post covers both of these approaches, by giving you an initial count of the number of participants, then notifying you of each joiner and leaver:

    [code language=”javascript”]


    Conversation State:
    Participants:




      [/code]

      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

      1 Comment

      1. Hi Tom,

        Great Post!

        All your posts in this series are Excellent! Very helpful!

        As Im trying to integrate Skype for business in my an application that I develop currently, I need to put a particular participant on hold which means I don’t want him to hear anything that others in the conference speaks for some time period till I enable him back. Is that possible? IsinLobby state that you have mentioned above has anything to do with this?

        Appreciate your help!

      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).