Cookie CSS

Saturday, May 6, 2017

Skype Web SDK - Part VI

What is the Skype Web SDK?

The Skype Developer Platform for Web ("Skype Web SDK") is a set of JavaScript Web APIs and HTML controls that enable you to build web experiences that seamlessly integrate a wide variety of real-time collaboration models leveraging Skype for Business services and the larger Skype network. It provides support for multiple core collaboration services like presence, chat, audio, and video, enabling web experiences across a broad spectrum of users, platforms, and devices.



Today's Topic : The AudioService (Continued)

Last week we looked at how to do things related to making audio calls and such.  Well that is only 1 part of dealing with audio, we also need to be able to react to incoming and incoming call.

Let's look at a complete piece of sample code then break it down.

conversationsManager.conversations.added(function (conversation) { conversation.audioService.accept.enabled.when(true, function () { if (confirm('Accept incoming Audio invitation?')) { conversation.audioService.accept(); conversation.participants.added(function (participant) { console.log('Participant:', participant.displayName(), 'has been added to the conversation'); }); } else { conversation.audioService.reject(); } }); conversation.state.changed(function (newValue, reason, oldValue) { console.log('Conversation state changed from', oldValue, 'to', newValue); }); });


At first glace it appears we have a lot going on here, functions inside of other functions, but it's not too difficult to follow if we break it down into pieces.

1.  Listen to all incoming call notifications.

application.conversationsManager.conversations.added(function (conversation) { // ... });


2.  When we get a notification we need to wait until we can accept the call

conversation.audioService.accept.enabled.when(true, function () { // .... })


3.  Prompt the user, and if they say yes, accept the call, otherwise reject

if (confirm('Accept incoming Audio invitation?')) { conversation.audioService.accept(); } else { conversation.audioService.reject(); }



4.  Notify our application when the state of the conversation changes, like the other party hangs up, that would certainly be handy to know :-)

conversation.state.changed(function (newValue, reason, oldValue) { //... });



5.  Notify our application when other participants join, we may have a much different conversation depending on the parties involved, so it's vital to know that information.

conversation.participants.added(function (participant) { // ... });



6.  Leave the conversation, this will disconnect the call if there are only 2 parties, but leave it be for the rest of the participants if there are at least 2 remaining.
.

conversation.leave().then(function () { // successfully left the conversation }, function (error) { // error }); // OR conversation.audioService.stop().then(function () { // successfully stopped audio }, function (error) { console.log("Failed to stop audio: " + error); });


That will wrap up this week, there is more to come next week.

Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC, 
Full Stack Developer  BridgeOC Bridge Operator Console
Twitter - @droutledge @ndbridge












No comments:

Post a Comment

Any spam comments will be deleted and your user account will be disabled.