Bridge Communications

Saturday, June 11, 2016

Skype for Business Response Group Add-on - Part II

Last week we laid our plan for building a response group add-on program to help organizations using response groups that are not in attendant mode.  I am happy to report the program is almost finished and the initial testing has been very good.  This week we will look at the code required to meet our requirements.

Step 1.  Define the settings we want to store in registry.

WrapTime - This will define how many seconds after a call ends we will set the user in a busy status with the note "Wrapping up" before setting them back to available so they can take another call.

StartMinimized - This will define whether or not the application will launch minimized to the system tray on launch.

Step 2.  Connect to the running Lync/Skype for Business client.

We are going to create a class called Globals and store this object here, in case it needs to be accessed form multiple windows in the future.

public static LyncClient lc;

In our main window on the Loaded method we'll do 2 things with this object.

                Globals.lc = LyncClient.GetClient();
                Globals.lc.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved;

The first is obvious as we make a connection to the existing client.  If the exe isn't running when we launch we will actually find it and launch it, preventing a issue that can occur if both are in the startup group on the computer.

The second is an event we will fire when a conversation is disconnected, giving us our location to start wrap up time.

That code will look like this.

 private void ConversationManager_ConversationRemoved(object sender, Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs e)
        {
            try
            {
                if (!Globals.HasAudioCall())
                {
                    Task.Factory.StartNew(() => 
                    {
                        Globals.isWrapUp = true;
                        System.Threading.Thread.Sleep(1000);
                        Globals.setLyncStatus(ContactAvailability.Busy, "Wrapping Up", "Wrapping Up");
                        System.Threading.Thread.Sleep(Convert.ToInt32(Globals.GetKey("WrapTime")) * 1000);
                        Globals.isWrapUp = false;
                    });
                }
            }
            catch { }
        }

We will flag a bool variable in Globals called isWrapUp, when this is set to true our main timer will skip over the process of setting the user to available.

Next week we will dig into our timer and some of the functions that it will use to manipulate the local client.


Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC Developer  BridgeOC
Twitter - @droutledge @ndbridge





No comments:

Post a Comment