SafeDispatch/SipComponent/ExtentionMethods.cs

31 lines
951 B
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using Independentsoft.Sip;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SipComponent
{
static class ExtentionMethods
{
/// <summary>
/// Gets the Dialog with the specified id
/// </summary>
/// <param name="sipClient">The object to which the method applies</param>
/// <param name="sipID">A sip Id with whom the SipClient class is in dialog</param>
/// <returns></returns>
public static Dialog GetDialogWith(this SipClient sipClient, string sipID)
{
return sipClient.Dialogs.FirstOrDefault((dialog) =>
{
if ((dialog.From.Address.Split(':', '@')[1] == sipID) ||
(dialog.To.Address.Split(':', '@')[1] == sipID))
return true;
else
return false;
});
}
}
}