本文整理汇总了C#中SIPSorcery.SIP.SIPRequest类的典型用法代码示例。如果您正苦于以下问题:C# SIPRequest类的具体用法?C# SIPRequest怎么用?C# SIPRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SIPRequest类属于SIPSorcery.SIP命名空间,在下文中一共展示了SIPRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecordDispatch
public void RecordDispatch(SIPRequest sipRequest, SIPEndPoint internalEndPoint)
{
lock(m_transactionEndPoints)
{
if (m_transactionEndPoints.ContainsKey(sipRequest.Header.CallId))
{
if (m_transactionEndPoints[sipRequest.Header.CallId] == internalEndPoint.ToString())
{
// The application server end point has not changed for this Call-Id
return;
}
else
{
// The application server end point has changed within the lifetime of the Call-Id. Remove the old mapping.
lock (m_transactionEndPoints)
{
m_transactionEndPoints.Remove(sipRequest.Header.CallId);
}
}
}
m_transactionEndPoints.Add(sipRequest.Header.CallId, internalEndPoint.ToString());
m_transactionIDAddedAt.Add(sipRequest.Header.CallId, DateTime.Now);
//ProxyLogger_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.SIPProxy, SIPMonitorEventTypesEnum.CallDispatcher, "Record dispatch for " + sipRequest.Method + " " + sipRequest.URI.ToString() + " to " + internalEndPoint.ToString() + " (id=" + transactionID + ").", null));
}
if (m_lastRemove < DateTime.Now.AddSeconds(REMOVE_EXPIREDS_SECONDS * -1))
{
RemoveExpiredDispatchRecords();
}
}
示例2: SIPNonInviteTransaction_TransactionRequestReceived
private void SIPNonInviteTransaction_TransactionRequestReceived(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPTransaction sipTransaction, SIPRequest sipRequest)
{
if (NonInviteRequestReceived != null)
{
NonInviteRequestReceived(localSIPEndPoint, remoteEndPoint, this, sipRequest);
}
}
示例3: UASInviteTransaction
internal UASInviteTransaction(
SIPTransport sipTransport,
SIPRequest sipRequest,
SIPEndPoint dstEndPoint,
SIPEndPoint localSIPEndPoint,
SIPEndPoint outboundProxy)
: base(sipTransport, sipRequest, dstEndPoint, localSIPEndPoint, outboundProxy)
{
TransactionType = SIPTransactionTypesEnum.Invite;
m_remoteTag = sipRequest.Header.From.FromTag;
if (sipRequest.Header.To.ToTag == null)
{
// This UAS needs to set the To Tag.
m_localTag = CallProperties.CreateNewTag();
}
else
{
// This is a re-INVITE.
m_localTag = sipRequest.Header.To.ToTag;
}
//logger.Debug("New UASTransaction (" + TransactionId + ") for " + TransactionRequest.URI.ToString() + " to " + RemoteEndPoint + ".");
CDR = new SIPCDR(SIPCallDirection.In, sipRequest.URI, sipRequest.Header.From, sipRequest.Header.CallId, LocalSIPEndPoint, dstEndPoint);
//UpdateTransactionState(SIPTransactionStatesEnum.Proceeding);
TransactionRequestReceived += UASInviteTransaction_TransactionRequestReceived;
TransactionInformationResponseReceived += UASInviteTransaction_TransactionResponseReceived;
TransactionFinalResponseReceived += UASInviteTransaction_TransactionResponseReceived;
TransactionTimedOut += UASInviteTransaction_TransactionTimedOut;
TransactionRemoved += UASInviteTransaction_TransactionRemoved;
}
示例4: SIPCancelTransaction_TransactionRequestReceived
private void SIPCancelTransaction_TransactionRequestReceived(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPTransaction sipTransaction, SIPRequest sipRequest)
{
try
{
//logger.Debug("CANCEL request received, attempting to locate and cancel transaction.");
//UASInviteTransaction originalTransaction = (UASInviteTransaction)GetTransaction(GetRequestTransactionId(sipRequest.Header.Via.TopViaHeader.Branch, SIPMethodsEnum.INVITE));
SIPResponse cancelResponse;
if (m_originalTransaction != null)
{
//logger.Debug("Transaction found to cancel " + originalTransaction.TransactionId + " type " + originalTransaction.TransactionType + ".");
m_originalTransaction.CancelCall();
cancelResponse = GetCancelResponse(sipRequest, SIPResponseStatusCodesEnum.Ok);
}
else
{
cancelResponse = GetCancelResponse(sipRequest, SIPResponseStatusCodesEnum.CallLegTransactionDoesNotExist);
}
//UpdateTransactionState(SIPTransactionStatesEnum.Completed);
SendFinalResponse(cancelResponse);
}
catch (Exception excp)
{
logger.Error("Exception SIPCancelTransaction GotRequest. " + excp.Message);
}
}
示例5: SIPCancelTransaction
internal SIPCancelTransaction(SIPTransport sipTransport, SIPRequest sipRequest, SIPEndPoint dstEndPoint, SIPEndPoint localSIPEndPoint, UASInviteTransaction originalTransaction)
: base(sipTransport, sipRequest, dstEndPoint, localSIPEndPoint, originalTransaction.OutboundProxy)
{
m_originalTransaction = originalTransaction;
TransactionType = SIPTransactionTypesEnum.NonInvite;
TransactionRequestReceived += SIPCancelTransaction_TransactionRequestReceived;
TransactionFinalResponseReceived += SIPCancelTransaction_TransactionFinalResponseReceived;
TransactionRemoved += SIPCancelTransaction_TransactionRemoved;
}
示例6: SIPNonInviteTransaction
internal SIPNonInviteTransaction(SIPTransport sipTransport, SIPRequest sipRequest, SIPEndPoint dstEndPoint, SIPEndPoint localSIPEndPoint, SIPEndPoint outboundProxy)
: base(sipTransport, sipRequest, dstEndPoint, localSIPEndPoint, outboundProxy)
{
TransactionType = SIPTransactionTypesEnum.NonInvite;
TransactionRequestReceived += SIPNonInviteTransaction_TransactionRequestReceived;
TransactionInformationResponseReceived += SIPNonInviteTransaction_TransactionInformationResponseReceived;
TransactionFinalResponseReceived += SIPNonInviteTransaction_TransactionFinalResponseReceived;
TransactionTimedOut += SIPNonInviteTransaction_TransactionTimedOut;
TransactionRemoved += SIPNonInviteTransaction_TransactionRemoved;
TransactionRequestRetransmit += SIPNonInviteTransaction_TransactionRequestRetransmit;
}
示例7: UACInviteTransaction
internal UACInviteTransaction(SIPTransport sipTransport, SIPRequest sipRequest, SIPEndPoint dstEndPoint, SIPEndPoint localSIPEndPoint, SIPEndPoint outboundProxy)
: base(sipTransport, sipRequest, dstEndPoint, localSIPEndPoint, outboundProxy)
{
TransactionType = SIPTransactionTypesEnum.Invite;
m_localTag = sipRequest.Header.From.FromTag;
CDR = new SIPCDR(SIPCallDirection.Out, sipRequest.URI, sipRequest.Header.From, sipRequest.Header.CallId, localSIPEndPoint, dstEndPoint);
TransactionFinalResponseReceived += UACInviteTransaction_TransactionFinalResponseReceived;
TransactionInformationResponseReceived += UACInviteTransaction_TransactionInformationResponseReceived;
TransactionTimedOut += UACInviteTransaction_TransactionTimedOut;
TransactionRequestReceived += UACInviteTransaction_TransactionRequestReceived;
TransactionRemoved += UACInviteTransaction_TransactionRemoved;
}
示例8: GetRequestIPAddress
public static IPAddress GetRequestIPAddress(SIPRequest sipRequest)
{
IPAddress requestIPAddress = null;
string remoteUAStr = sipRequest.Header.ProxyReceivedFrom;
if (!remoteUAStr.IsNullOrBlank())
{
requestIPAddress = SIPEndPoint.ParseSIPEndPoint(remoteUAStr).Address;
}
else if (sipRequest.RemoteSIPEndPoint != null)
{
requestIPAddress = sipRequest.RemoteSIPEndPoint.Address;
}
return requestIPAddress;
}
示例9: GetCancelResponse
private SIPResponse GetCancelResponse(SIPRequest sipRequest, SIPResponseStatusCodesEnum sipResponseCode)
{
try
{
SIPResponse cancelResponse = new SIPResponse(sipResponseCode, null, sipRequest.LocalSIPEndPoint);
SIPHeader requestHeader = sipRequest.Header;
cancelResponse.Header = new SIPHeader(requestHeader.From, requestHeader.To, requestHeader.CSeq, requestHeader.CallId);
cancelResponse.Header.CSeqMethod = SIPMethodsEnum.CANCEL;
cancelResponse.Header.Vias = requestHeader.Vias;
cancelResponse.Header.MaxForwards = Int32.MinValue;
return cancelResponse;
}
catch (Exception excp)
{
logger.Error("Exception GetCancelResponse. " + excp.Message);
throw excp;
}
}
示例10: RTPDiagnosticsJob
/// <param name="rtpListenAddress">The local IP address to establish the RTP listener socket on.</param>
/// <param name="sdpAdvertiseAddress">The public IP address to put into the SDP sent back to the caller.</param>
/// <param name="request">The INVITE request that instigated the RTP diagnostics job.</param>
public RTPDiagnosticsJob(IPAddress rtpListenAddress, IPAddress sdpAdvertiseAddress, SIPServerUserAgent uas, SIPRequest request)
{
m_request = request;
m_remoteSDP = SDP.ParseSDPDescription(request.Body);
RemoteRTPEndPoint = new IPEndPoint(IPAddress.Parse(m_remoteSDP.Connection.ConnectionAddress), m_remoteSDP.Media[0].Port);
UAS = uas;
//m_rawSourceStream = new RawSourceWaveStream(m_outStream, WaveFormat.CreateMuLawFormat(8000, 1));
//m_waveFileWriter = new WaveFileWriter("out.wav", new WaveFormat(8000, 16, 1));
m_waveFileWriter = new WaveFileWriter("out.wav", new WaveFormat(8000, 16, 1));
//m_outPCMStream = WaveFormatConversionStream.CreatePcmStream(m_rawSourceStream);
//m_rawRTPPayloadWriter = new StreamWriter("out.rtp");
//m_rawRTPPayloadReader = new StreamReader("in.rtp");
//IPEndPoint rtpListenEndPoint = null;
IPEndPoint rtpListenEndPoint = null;
NetServices.CreateRandomUDPListener(rtpListenAddress, RTP_PORTRANGE_START, RTP_PORTRANGE_END, m_inUsePorts, out rtpListenEndPoint);
RTPListenEndPoint = rtpListenEndPoint;
m_inUsePorts.Add(rtpListenEndPoint.Port);
//RTPListenEndPoint = new IPEndPoint(rtpListenAddress, RTP_PORTRANGE_START);
m_rtpChannel = new RTPChannel(RTPListenEndPoint);
m_rtpChannel.SampleReceived += SampleReceived;
ThreadPool.QueueUserWorkItem(delegate { GetAudioSamples(); });
LocalSDP = new SDP()
{
SessionId = Crypto.GetRandomString(6),
Address = sdpAdvertiseAddress.ToString(),
SessionName = "sipsorcery",
Timing = "0 0",
Connection = new SDPConnectionInformation(sdpAdvertiseAddress.ToString()),
Media = new List<SDPMediaAnnouncement>()
{
new SDPMediaAnnouncement()
{
Media = SDPMediaTypesEnum.audio,
Port = RTPListenEndPoint.Port,
MediaFormats = new List<SDPMediaFormat>() { new SDPMediaFormat((int)SDPMediaFormatsEnum.PCMU) }
}
}
};
}
示例11: GetDialPlanExactMatch
/// <summary>
/// Used for incoming calls where an exact match is required on the sipswitch username.
/// </summary>
public DialPlanCommand GetDialPlanExactMatch(SIPRequest sipRequest)
{
try
{
//LastUsed = DateTime.Now;
if (m_commands.Count > 0)
{
bool match = false;
foreach (DialPlanCommand dialPlanCommand in m_commands)
{
switch (dialPlanCommand.Operation)
{
case DialPlanOpsEnum.Equals:
match = (dialPlanCommand.Destination == sipRequest.URI.User);
break;
default:
break;
}
if (match)
{
logger.Debug("Dial Plan Exact Match for " + sipRequest.URI.User + " and " + dialPlanCommand.ToString());
return dialPlanCommand;
}
}
}
return null;
}
catch (Exception excp)
{
logger.Error("Exception GetDialPlanExactMatch. " + excp.Message);
throw excp;
}
}
示例12: LookupTransactionID
public SIPEndPoint LookupTransactionID(SIPRequest sipRequest)
{
try
{
SIPEndPoint transactionEndPoint = LookupTransactionID(sipRequest.Header.CallId);
if (transactionEndPoint != null)
{
return transactionEndPoint;
}
else if (sipRequest.Method == SIPMethodsEnum.INVITE && !sipRequest.URI.User.IsNullOrBlank())
{
string toUser = (sipRequest.URI.User.IndexOf('.') != -1) ? sipRequest.URI.User.Substring(sipRequest.URI.User.LastIndexOf('.') + 1) : sipRequest.URI.User;
if (m_userCallbacks.ContainsKey(toUser))
{
SIPEndPoint callbackEndPoint = null;
callbackEndPoint = SIPEndPoint.ParseSIPEndPoint(m_userCallbacks[toUser].DesintationEndPoint);
RecordDispatch(sipRequest, callbackEndPoint);
ProxyLogger_External(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.SIPProxy, SIPMonitorEventTypesEnum.DialPlan, "SIP Proxy directing incoming call for user " + toUser + " to application server " + callbackEndPoint.ToString() + ".", toUser));
lock (m_userCallbacks)
{
m_userCallbacks.Remove(toUser);
}
return callbackEndPoint;
}
}
return null;
}
catch (Exception excp)
{
logger.Error("Exception LookupTransactionID. " + excp.Message);
return null;
}
}
示例13: SendRequest
public void SendRequest(SIPEndPoint dstEndPoint, SIPRequest sipRequest)
{
if (dstEndPoint != null && dstEndPoint.Address.Equals(BlackholeAddress))
{
// Ignore packet, it's destined for the blackhole.
return;
}
if (m_sipChannels.Count == 0)
{
throw new ApplicationException("No channels are configured in the SIP transport layer. The request could not be sent.");
}
SIPChannel sipChannel = null;
if (sipRequest.LocalSIPEndPoint != null)
{
sipChannel = FindSIPChannel(sipRequest.LocalSIPEndPoint);
sipChannel = sipChannel ?? GetDefaultChannel(sipRequest.LocalSIPEndPoint.Protocol);
}
else
{
sipChannel = GetDefaultChannel(dstEndPoint.Protocol);
}
if (sipChannel != null)
{
SendRequest(sipChannel, dstEndPoint, sipRequest);
}
else
{
throw new ApplicationException("A default SIP channel could not be found for protocol " + sipRequest.LocalSIPEndPoint.Protocol + " when sending SIP request.");
}
}
示例14: PreProcessRouteInfo
/// <summary>
/// This function performs processing on a request to handle any actions that need to be taken based on the Route header.
/// </summary>
/// <remarks>
/// The main sections in the RFC3261 dealing with Route header processing are sections 12.2.1.1 for request processing and
/// 16.4 for proxy processing.
/// The steps to process requests for Route headers are:
/// 1. If route set is empty no further action is required, forward to destination resolved from request URI,
/// 2. If the request URI is identified as a value that was previously set as a Route by this SIP agent it means the
/// previous hop was a strict router. Replace the reqest URI with the last Route header and go to next step,
/// 3. If the top most route header was set by this SIP agent then remove it and go to next step,
/// 4. If the top most route set does contain the lr parameter then forward to the destination resolved by it,
/// 5. If the top most route header does NOT contain the lr parameter is must be popped and inserted as the request URI
/// and the original request URI must be added to the end of the route set, forward to destination resolved from request URI,
/// </remarks>
public void PreProcessRouteInfo(SIPRequest sipRequest)
{
// If there are no routes defined then there is nothing to do.
if (sipRequest.Header.Routes != null && sipRequest.Header.Routes.Length > 0)
{
// If this stack's route URI is being used as the request URI then it will have the loose route parameter (see remarks step 2).
if (sipRequest.URI.Parameters.Has(m_looseRouteParameter))
{
foreach (SIPChannel sipChannel in m_sipChannels.Values)
{
if (sipRequest.URI.ToSIPEndPoint() == sipChannel.SIPChannelEndPoint)
{
// The request URI was this router's address so it was set by a strict router.
// Replace the URI with the original SIP URI that is stored at the end of the route header.
sipRequest.URI = sipRequest.Header.Routes.BottomRoute.URI;
sipRequest.Header.Routes.RemoveBottomRoute();
}
}
}
// The possibility of a strict router on the previous hop has now been handled.
if (sipRequest.Header.Routes != null && sipRequest.Header.Routes.Length > 0)
{
// Check whether the top route header belongs to this proxy (see remarks step 3).
if (!sipRequest.Header.Routes.TopRoute.IsStrictRouter)
{
foreach (SIPChannel sipChannel in m_sipChannels.Values)
{
if (sipRequest.Header.Routes.TopRoute.ToSIPEndPoint() == sipChannel.SIPChannelEndPoint)
{
// Remove the top route as it belongs to this proxy.
sipRequest.ReceivedRoute = sipRequest.Header.Routes.PopRoute();
break;
}
}
}
// Check whether the top route header is a strict router and if so adjust the request accordingly (see remarks step 5).
if (sipRequest.Header.Routes != null && sipRequest.Header.Routes.Length > 0)
{
if (sipRequest.Header.Routes.TopRoute.IsStrictRouter)
{
// Put the strict router's uri into the request URI and place the original request URI at the end of the route set.
SIPRoute strictRoute = sipRequest.Header.Routes.PopRoute();
SIPRoute uriRoute = new SIPRoute(sipRequest.URI);
sipRequest.Header.Routes.AddBottomRoute(uriRoute);
sipRequest.URI = strictRoute.URI;
}
}
}
}
}
示例15: GetTransaction
public SIPTransaction GetTransaction(SIPRequest sipRequest)
{
CheckTransactionEngineExists();
return m_transactionEngine.GetTransaction(sipRequest);
}