When using the Lync client sdk rule #1 is always having Lync/Skype4b running, then declare a variable and attach to the running Lync client.
Microsoft.Lync.Model.LyncClient _LyncClient;
_LyncClient = LyncClient.GetClient();
After that we really only need 2 things to make our app happen.
1. The conversation we want to add the new party to.
2. The URI of the new party to add.
We will accomplish this work by passing this information to our procedure shown below.
public static void AddConferenceParticipant(Conversation c, string part)
{
if (c == null)
return;
Task.Factory.StartNew(() =>
{
try
{
foreach (Participant p in c.Participants)
{
if (p != c.SelfParticipant)
{
logAction("ADDCONF", part );
}
}
}
catch { }
});
try
{
if (c.CanInvoke(ConversationAction.AddParticipant))
{
Console.WriteLine("Adding " + part + " to Call as Conference");
c.AddParticipant(lc.ContactManager.GetContactByUri(part));
}
}
catch (Exception ex)
{
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(ex, true);
string er;
er = "AddConferenceParticipant: Error Trapped in " + Dlib.ProgramSource + ".\r\n";
er = er + trace.GetFrame(0).GetMethod().Name + "\r\n" + ex.Message.ToString();
er = er + "Line: " + trace.GetFrame(0).GetFileLineNumber();
er = er + "Column: " + trace.GetFrame(0).GetFileColumnNumber();
Dlib.report_error(er);
}
}
Now there is some extra error handling in this block above, which makes sure there is an actual conversation that isn't null passed. I also have an action logging routine which is helpful in the case of a error, or the need to find out who added whom to the call.
That will wrap up this week, short and sweet, thanks for stopping by the read.
Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC Developer BridgeOC
Twitter - @droutledge @ndbridge
Twitter - @droutledge @ndbridge
No comments:
Post a Comment
Any spam comments will be deleted and your user account will be disabled.