public void ParseFromHeaderTest() { Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); string testFromHeader = "\"User\" <sip:[email protected]>;tag=abcdef"; SIPFromHeader sipFromHeader = SIPFromHeader.ParseFromHeader(testFromHeader); Console.WriteLine("From header=" + sipFromHeader.ToString() + "."); Assert.IsTrue(sipFromHeader.FromName == "User", "The From header name was not parsed correctly."); Assert.IsTrue(sipFromHeader.FromURI.ToString() == "sip:[email protected]", "The From header URI was not parsed correctly."); Assert.IsTrue(sipFromHeader.FromTag == "abcdef", "The From header Tag was not parsed correctly."); Assert.IsTrue(sipFromHeader.ToString() == testFromHeader, "The From header ToString method did not produce the correct results."); }
public SIPRequest GetReferRequest(SIPRequest inviteRequest, SIPResponse inviteResponse, string referToURI) { SIPRequest referRequest = new SIPRequest(SIPMethodsEnum.REFER, inviteRequest.URI); SIPHeader referHeader = new SIPHeader(inviteResponse.Header.From, inviteResponse.Header.To, inviteRequest.Header.CSeq + 1, inviteRequest.Header.CallId); referHeader.Contact = inviteRequest.Header.Contact; referHeader.CSeqMethod = SIPMethodsEnum.REFER; referHeader.ReferTo = referToURI; SIPFromHeader referredBy = new SIPFromHeader(inviteRequest.Header.From.FromName, inviteRequest.Header.From.FromURI, null); referHeader.ReferredBy = referredBy.ToString(); referHeader.AuthenticationHeader = inviteRequest.Header.AuthenticationHeader; IPEndPoint localSIPEndPoint = m_sipTransport.GetIPEndPointsList()[0]; SIPViaHeader viaHeader = new SIPViaHeader(localSIPEndPoint.Address.ToString(), localSIPEndPoint.Port, CallProperties.CreateBranchId()); referHeader.Via.PushViaHeader(viaHeader); referRequest.Header = referHeader; return(referRequest); }
public SIPRequest GetReferRequest(SIPRequest inviteRequest, SIPResponse inviteResponse, string referToURI) { SIPRequest referRequest = new SIPRequest(SIPMethodsEnum.REFER, inviteRequest.URI); SIPHeader referHeader = new SIPHeader(inviteResponse.Header.From, inviteResponse.Header.To, inviteRequest.Header.CSeq + 1, inviteRequest.Header.CallId); referHeader.Contact = inviteRequest.Header.Contact; referHeader.CSeqMethod = SIPMethodsEnum.REFER; referHeader.ReferTo = referToURI; SIPFromHeader referredBy = new SIPFromHeader(inviteRequest.Header.From.FromName, inviteRequest.Header.From.FromURI, null); referHeader.ReferredBy = referredBy.ToString(); referHeader.AuthenticationHeader = inviteRequest.Header.AuthenticationHeader; IPEndPoint localSIPEndPoint = m_sipTransport.GetIPEndPointsList()[0]; SIPViaHeader viaHeader = new SIPViaHeader(localSIPEndPoint.Address.ToString(), localSIPEndPoint.Port, CallProperties.CreateBranchId()); referHeader.Via.PushViaHeader(viaHeader); referRequest.Header = referHeader; return referRequest; }