本文整理汇总了C#中SIPSorcery.SIP.SIPTransport.CreateUASTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# SIPTransport.CreateUASTransaction方法的具体用法?C# SIPTransport.CreateUASTransaction怎么用?C# SIPTransport.CreateUASTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIPSorcery.SIP.SIPTransport
的用法示例。
在下文中一共展示了SIPTransport.CreateUASTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AckRecognitionUnitTest
public void AckRecognitionUnitTest()
{
SIPTransport clientTransport = null;
SIPTransport serverTransport = null;
try
{
SIPTransactionEngine clientEngine = new SIPTransactionEngine(); // Client side of the INVITE.
SIPEndPoint clientEndPoint = new SIPEndPoint(SIPProtocolsEnum.udp, new IPEndPoint(IPAddress.Loopback, 12013));
clientTransport = new SIPTransport(MockSIPDNSManager.Resolve, clientEngine, new SIPUDPChannel(clientEndPoint.GetIPEndPoint()), false);
SetTransportTraceEvents(clientTransport);
SIPTransactionEngine serverEngine = new SIPTransactionEngine(); // Server side of the INVITE.
UASInviteTransaction serverTransaction = null;
SIPEndPoint serverEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Loopback, 12014));
serverTransport = new SIPTransport(MockSIPDNSManager.Resolve, serverEngine, new SIPUDPChannel(serverEndPoint.GetIPEndPoint()), false);
SetTransportTraceEvents(serverTransport);
serverTransport.SIPTransportRequestReceived += (localEndPoint, remoteEndPoint, sipRequest) =>
{
Console.WriteLine("Server Transport Request In: " + sipRequest.Method + ".");
serverTransaction = serverTransport.CreateUASTransaction(sipRequest, remoteEndPoint, localEndPoint, null);
SetTransactionTraceEvents(serverTransaction);
serverTransaction.GotRequest(localEndPoint, remoteEndPoint, sipRequest);
};
SIPURI dummyURI = SIPURI.ParseSIPURI("sip:[email protected]" + serverEndPoint);
SIPRequest inviteRequest = GetDummyINVITERequest(dummyURI);
inviteRequest.LocalSIPEndPoint = clientTransport.GetDefaultTransportContact(SIPProtocolsEnum.udp);
// Send the invite to the server side.
UACInviteTransaction clientTransaction = new UACInviteTransaction(clientTransport, inviteRequest, serverEndPoint, clientEndPoint, null);
SetTransactionTraceEvents(clientTransaction);
clientEngine.AddTransaction(clientTransaction);
clientTransaction.SendInviteRequest(serverEndPoint, inviteRequest);
Thread.Sleep(500);
Assert.IsTrue(clientTransaction.TransactionState == SIPTransactionStatesEnum.Completed, "Client transaction in incorrect state.");
Assert.IsTrue(serverTransaction.TransactionState == SIPTransactionStatesEnum.Confirmed, "Server transaction in incorrect state.");
}
finally
{
if (clientTransport != null)
{
clientTransport.Shutdown();
}
if (serverTransport != null)
{
serverTransport.Shutdown();
}
}
}