Pages Menu
TwitterRssFacebook

Posted by on Jun 8, 2015 in Everything Else

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

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

[contemplate-1]
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.
      [contemplate-2]

      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 *