本文整理汇总了C#中SIPSorcery.SIP.SIPEndPoint.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SIPEndPoint.ToString方法的具体用法?C# SIPEndPoint.ToString怎么用?C# SIPEndPoint.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIPSorcery.SIP.SIPEndPoint
的用法示例。
在下文中一共展示了SIPEndPoint.ToString方法的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: IsAppServerEndPoint
public bool IsAppServerEndPoint(SIPEndPoint remoteEndPoint)
{
if (m_appServerEndPoints == null || m_appServerEndPoints.Count == 0)
{
return false;
}
else
{
return m_appServerEndPoints.ContainsKey(remoteEndPoint.ToString());
}
}
示例3: IsSIPEndPointMonitored
public override bool IsSIPEndPointMonitored(SIPEndPoint sipEndPoint)
{
lock (m_activeAppServerEntry)
{
foreach (AppServerEntry appServerEntry in m_appServerEntries)
{
if (new SIPEndPoint(appServerEntry.AppServerURI).ToString() == sipEndPoint.ToString())
{
return true;
}
}
}
return false;
}
示例4: sipTransport2_SIPResponseOutTraceEvent
void sipTransport2_SIPResponseOutTraceEvent(SIPEndPoint localEndPoint, SIPEndPoint toEndPoint, SIPResponse sipResponse)
{
Console.WriteLine("Response Sent: " + localEndPoint.ToString() + "<-" + toEndPoint.ToString() + "\r\n" + sipResponse.ToString());
}
示例5: SendInternal
/// <summary>
/// Used to send a SIP request received from an external user agent to an internal SIP server agent.
/// </summary>
/// <param name="receivedFromEP">The SIP end point the proxy received the request from.</param>
/// <param name="receivedOnEP">The SIP end point the proxy received the request on.</param>
/// <param name="dstSocket">The internal socket to send the request to.</param>
/// <param name="sipRequest">The SIP request to send.</param>
/// <param name="proxyBranch">The branch to set on the Via header when sending the request. The branch should be calculated
/// by the proxy core so that looped requests can be detected.</param>
/// <param name="sendFromSocket">The proxy socket to send the request from.</param>
public void SendInternal(SIPEndPoint receivedFromEP, SIPEndPoint receivedOnEP, string dstSocket, SIPRequest sipRequest, string proxyBranch, string sendFromSocket)
{
try
{
if (!IsDestinationValid(sipRequest, dstSocket))
{
logger.Debug("SendInternal failed destination check.");
return;
}
sipRequest.Header.ProxyReceivedFrom = receivedFromEP.ToString();
sipRequest.Header.ProxyReceivedOn = receivedOnEP.ToString();
SIPEndPoint dstSIPEndPoint = SIPEndPoint.ParseSIPEndPoint(dstSocket);
SIPEndPoint localSIPEndPoint = SIPEndPoint.ParseSIPEndPoint(sendFromSocket);
if (receivedOnEP != localSIPEndPoint)
{
// The proxy is being requested to send the request on a different socket to the one it was received on.
// A second Via header is added to ensure the response can navigate back the same path. The calculated branch
// parameter needs to go on the top Via header so that whichever internal socket the request is being sent to can
// determine re-transmits.
SIPViaHeader via = new SIPViaHeader(receivedOnEP, CallProperties.CreateBranchId());
sipRequest.Header.Vias.PushViaHeader(via);
SIPViaHeader topVia = new SIPViaHeader(localSIPEndPoint, proxyBranch);
sipRequest.Header.Vias.PushViaHeader(topVia);
}
else
{
// Only a single Via header is required as any response to this request will be sent from the same socket it gets received on.
SIPViaHeader via = new SIPViaHeader(localSIPEndPoint, proxyBranch);
sipRequest.Header.Vias.PushViaHeader(via);
}
sipRequest.LocalSIPEndPoint = localSIPEndPoint;
m_sipTransport.SendRequest(dstSIPEndPoint, sipRequest);
}
catch (Exception excp)
{
logger.Error("Exception SIPRequest SendInternal. " + excp.Message);
logger.Error(sipRequest.ToString());
throw;
}
}
示例6: LogSIPRequestIn
private void LogSIPRequestIn(SIPEndPoint localSIPEndPoint, SIPEndPoint endPoint, SIPRequest sipRequest)
{
string message = "App Svr Received: " + localSIPEndPoint.ToString() + "<-" + endPoint.ToString() + "\r\n" + sipRequest.ToString();
//logger.Debug("as: request in " + sipRequest.Method + " " + localSIPEndPoint.ToString() + "<-" + endPoint.ToString() + ", callid=" + sipRequest.Header.CallId + ".");
string fromUser = (sipRequest.Header.From != null && sipRequest.Header.From.FromURI != null) ? sipRequest.Header.From.FromURI.User : "Error on From header";
FireSIPMonitorEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.FullSIPTrace, message, fromUser, localSIPEndPoint, endPoint));
}
示例7: SIPResponseOutTraceEvent
private static void SIPResponseOutTraceEvent(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPResponse sipResponse)
{
logger.DebugFormat("RESPONSE OUT {0}->{1}", localSIPEndPoint.ToString(), remoteEndPoint.ToString());
logger.Debug(sipResponse.ToString());
}
示例8: FindSIPChannel
/// <summary>
/// Attempts to match a SIPChannel for this process that has the specified local end point and protocol.
/// </summary>
/// <param name="localEndPoint">The local socket endpoint of the SIPChannel to find.</param>
/// <returns>A matching SIPChannel if found otherwise null.</returns>
public SIPChannel FindSIPChannel(SIPEndPoint localSIPEndPoint)
{
//bool isEqual = (localSIPEndPoint == m_sipChannels.Keys.First<SIPEndPoint>());
//logger.Debug("Searching for SIP channel for endpoint " + localSIPEndPoint.ToString() + ". First channel in transport list is " + m_sipChannels.Keys.First().ToString() + ". " + m_sipChannels.Keys.Contains(localSIPEndPoint) + ", " + isEqual);
if (localSIPEndPoint == null)
{
return null;
}
else
{
if (m_sipChannels.ContainsKey(localSIPEndPoint.ToString()))
{
return m_sipChannels[localSIPEndPoint.ToString()];
}
else
{
logger.Warn("No SIP channel could be found for local SIP end point " + localSIPEndPoint.ToString() + ".");
return null;
}
}
}
示例9: SendRaw
/// <summary>
/// Allows raw bytes to be sent from one of the SIPTransport sockets. This should not be used for SIP payloads and instead is
/// provided to allow other types of payloads to be multi-plexed on the SIP socket. Examples are sending NAT keep alives and
/// STUN responses where it's useful to use the same socket as the SIP packets.
/// </summary>
public void SendRaw(SIPEndPoint localSIPEndPoint, SIPEndPoint destinationEndPoint, byte[] buffer)
{
if (destinationEndPoint != null && destinationEndPoint.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 data could not be sent.");
}
SIPChannel sendSIPChannel = FindSIPChannel(localSIPEndPoint);
if (sendSIPChannel != null)
{
sendSIPChannel.Send(destinationEndPoint.GetIPEndPoint(), buffer);
}
else
{
logger.Warn("No SIPChannel could be found for " + localSIPEndPoint + " in SIPTransport.SendRaw, sending to " + destinationEndPoint.ToString() + ".");
//logger.Warn(Encoding.UTF8.GetString(buffer));
}
}
示例10: AddRegisterRequest
public void AddRegisterRequest(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPRequest registerRequest)
{
try
{
if (registerRequest.Method != SIPMethodsEnum.REGISTER)
{
SIPResponse notSupportedResponse = GetErrorResponse(registerRequest, SIPResponseStatusCodesEnum.MethodNotAllowed, "Registration requests only");
m_sipTransport.SendResponse(notSupportedResponse);
}
else
{
SIPSorceryPerformanceMonitor.IncrementCounter(SIPSorceryPerformanceMonitor.REGISTRAR_REGISTRATION_REQUESTS_PER_SECOND);
int requestedExpiry = GetRequestedExpiry(registerRequest);
if (registerRequest.Header.To == null)
{
logger.Debug("Bad register request, no To header from " + remoteEndPoint + ".");
SIPResponse badReqResponse = SIPTransport.GetResponse(registerRequest, SIPResponseStatusCodesEnum.BadRequest, "Missing To header");
m_sipTransport.SendResponse(badReqResponse);
}
else if(registerRequest.Header.To.ToURI.User.IsNullOrBlank())
{
logger.Debug("Bad register request, no To user from " + remoteEndPoint + ".");
SIPResponse badReqResponse = SIPTransport.GetResponse(registerRequest, SIPResponseStatusCodesEnum.BadRequest, "Missing username on To header");
m_sipTransport.SendResponse(badReqResponse);
}
else if (registerRequest.Header.Contact == null || registerRequest.Header.Contact.Count == 0)
{
logger.Debug("Bad register request, no Contact header from " + remoteEndPoint + ".");
SIPResponse badReqResponse = SIPTransport.GetResponse(registerRequest, SIPResponseStatusCodesEnum.BadRequest, "Missing Contact header");
m_sipTransport.SendResponse(badReqResponse);
}
else if (requestedExpiry > 0 && requestedExpiry < m_minimumBindingExpiry)
{
logger.Debug("Bad register request, no expiry of " + requestedExpiry + " to small from " + remoteEndPoint + ".");
SIPResponse tooFrequentResponse = GetErrorResponse(registerRequest, SIPResponseStatusCodesEnum.IntervalTooBrief, null);
tooFrequentResponse.Header.MinExpires = m_minimumBindingExpiry;
m_sipTransport.SendResponse(tooFrequentResponse);
}
else
{
if (m_registerQueue.Count < MAX_REGISTER_QUEUE_SIZE)
{
SIPNonInviteTransaction registrarTransaction = m_sipTransport.CreateNonInviteTransaction(registerRequest, remoteEndPoint, localSIPEndPoint, null);
lock (m_registerQueue)
{
m_registerQueue.Enqueue(registrarTransaction);
}
FireProxyLogEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.Registrar, SIPMonitorEventTypesEnum.BindingInProgress, "Register queued for " + registerRequest.Header.To.ToURI.ToString() + ".", null));
}
else
{
logger.Error("Register queue exceeded max queue size " + MAX_REGISTER_QUEUE_SIZE + ", overloaded response sent.");
SIPResponse overloadedResponse = SIPTransport.GetResponse(registerRequest, SIPResponseStatusCodesEnum.TemporarilyUnavailable, "Registrar overloaded, please try again shortly");
m_sipTransport.SendResponse(overloadedResponse);
}
m_registerARE.Set();
}
}
}
catch (Exception excp)
{
logger.Error("Exception AddRegisterRequest (" + remoteEndPoint.ToString() + "). " + excp.Message);
}
}
示例11: UACInviteTransaction_TransactionRequestReceived
private void UACInviteTransaction_TransactionRequestReceived(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPTransaction sipTransaction, SIPRequest sipRequest)
{
logger.Warn("UACInviteTransaction received unexpected request, " + sipRequest.Method + " from " + remoteEndPoint.ToString() + ", ignoring.");
}
示例12: DispatchRequest
public void DispatchRequest(SIPEndPoint dispatchEndPoint, SIPRequest sipRequest) {
FireProxyLogEvent(new SIPMonitorControlClientEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "Dispatching new " + sipRequest.Method + " request to " + dispatchEndPoint.ToString() + ", callid=" + sipRequest.Header.CallId + ".", null));
m_callIdEndPoints.Add(sipRequest.Header.CallId, dispatchEndPoint.ToString());
m_callIdAddedAt.Add(sipRequest.Header.CallId, DateTime.Now);
m_sipTransport.SendRequest(dispatchEndPoint, sipRequest);
}
示例13: GotRequest
/// <summary>
/// From RFC3261: Stateless Proxy Request Processing:
///
/// For each target, the proxy forwards the request following these
/// 1. Make a copy of the received request
/// 2. Update the Request-URI
/// 3. Update the Max-Forwards header field
/// 4. Optionally add a Record-route header field value
/// 5. Optionally add additional header fields
/// 6. Postprocess routing information
/// 7. Determine the next-hop address, port, and transport
/// 8. Add a Via header field value
/// 9. Add a Content-Length header field if necessary
/// 10. Forward the new request
///
/// See sections 12.2.1.1 and 16.12.1.2 in the SIP RFC for the best explanation on the way the Route header works.
/// </summary>
/// <param name="sipRequest"></param>
/// <param name="inEndPoint">End point the request was received on.</param>
/// <param name="sipChannel"></param>
private void GotRequest(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPRequest sipRequest)
{
try
{
// Calculate the proxy branch parameter for this request. The branch parameter has to be calculated so that INVITE's and CANCEL's generate the same branchid.
//string toTag = (sipRequest.Header.To != null) ? sipRequest.Header.To.ToTag : null;
//string fromTag = (sipRequest.Header.From != null) ? sipRequest.Header.From.FromTag : null;
string route = (sipRequest.Header.Routes != null) ? sipRequest.Header.Routes.ToString() : null;
//string authHeader = (sipRequest.Header.AuthenticationHeader != null) ? sipRequest.Header.AuthenticationHeader.ToString() : null;
string proxyBranch = CallProperties.CreateBranchId(SIPConstants.SIP_BRANCH_MAGICCOOKIE, null, null, sipRequest.Header.CallId, sipRequest.URI.ToString(), null, sipRequest.Header.CSeq, route, null, null);
// Check whether the branch parameter already exists in the Via list. One instance of an already added Via header will be allowed to support a single spiral.
int loopedViaCount = 0;
foreach (SIPViaHeader viaHeader in sipRequest.Header.Vias.Via)
{
//if (viaHeader.Branch == proxyBranch)
SIPEndPoint sentFromEndPoint = SIPEndPoint.TryParse(viaHeader.Transport + ":" + viaHeader.ContactAddress);
if (sentFromEndPoint != null && m_sipTransport.IsLocalSIPEndPoint(sentFromEndPoint))
{
loopedViaCount++;
}
if (loopedViaCount >= 2)
{
SendMonitorEvent(new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.SIPProxy, SIPMonitorEventTypesEnum.Warn, "Loop detected on request from " + remoteEndPoint + " to " + sipRequest.URI.ToString() + ".", null));
m_sipTransport.SendResponse(SIPTransport.GetResponse(sipRequest, SIPResponseStatusCodesEnum.LoopDetected, null));
return;
}
}
// Used in the proxy monitor messages only, plays no part in request routing.
string fromUser = (sipRequest.Header.From != null) ? sipRequest.Header.From.FromURI.User : null;
string toUser = (sipRequest.Header.To != null) ? sipRequest.Header.To.ToURI.User : null;
string summaryStr = "req " + sipRequest.Method + " from=" + fromUser + ", to=" + toUser + ", " + remoteEndPoint.ToString();
bool isFromAppServer = (m_sipCallDispatcherFile != null) ? m_sipCallDispatcherFile.IsAppServerEndPoint(remoteEndPoint) : false;
lock (this)
{
m_compiledScript.DefaultScope.RemoveVariable("sys");
m_compiledScript.DefaultScope.RemoveVariable("localEndPoint");
m_compiledScript.DefaultScope.RemoveVariable("isreq");
m_compiledScript.DefaultScope.RemoveVariable("req");
m_compiledScript.DefaultScope.RemoveVariable("remoteEndPoint");
m_compiledScript.DefaultScope.RemoveVariable("summary");
m_compiledScript.DefaultScope.RemoveVariable("proxyBranch");
m_compiledScript.DefaultScope.RemoveVariable("sipMethod");
m_compiledScript.DefaultScope.RemoveVariable("publicip");
m_compiledScript.DefaultScope.RemoveVariable("IsFromAppServer");
m_compiledScript.DefaultScope.SetVariable("sys", m_proxyScriptFacade);
m_compiledScript.DefaultScope.SetVariable("localEndPoint", localSIPEndPoint);
m_compiledScript.DefaultScope.SetVariable("isreq", true);
m_compiledScript.DefaultScope.SetVariable("req", sipRequest);
m_compiledScript.DefaultScope.SetVariable("remoteEndPoint", remoteEndPoint);
m_compiledScript.DefaultScope.SetVariable("summary", summaryStr);
m_compiledScript.DefaultScope.SetVariable("proxyBranch", proxyBranch);
m_compiledScript.DefaultScope.SetVariable("sipMethod", sipRequest.Method.ToString());
m_compiledScript.DefaultScope.SetVariable("publicip", PublicIPAddress);
m_compiledScript.DefaultScope.SetVariable("IsFromAppServer", isFromAppServer);
m_compiledScript.Execute();
}
//if (requestStopwatch.ElapsedMilliseconds > 20)
//{
// logger.Debug("GotRequest processing time=" + requestStopwatch.ElapsedMilliseconds + "ms, script time=" + scriptStopwatch.ElapsedMilliseconds + "ms.");
//}
}
catch (SIPValidationException)
{
throw;
}
catch (Exception excp)
{
string remoteEndPointStr = (remoteEndPoint != null) ? remoteEndPoint.ToString() : null;
string reqExcpError = "Exception SIPProxyCore GotRequest (from " + remoteEndPointStr + "). " + excp.Message;
logger.Error(reqExcpError);
SIPMonitorEvent reqExcpEvent = new SIPMonitorConsoleEvent(SIPMonitorServerTypesEnum.SIPProxy, SIPMonitorEventTypesEnum.Error, reqExcpError, localSIPEndPoint, remoteEndPoint, null);
SendMonitorEvent(reqExcpEvent);
//.........这里部分代码省略.........
示例14: IsWorkerSIPEndPoint
public bool IsWorkerSIPEndPoint(SIPEndPoint remoteEndPoint) {
return m_workerSIPEndPoints.Contains(remoteEndPoint.ToString());
}
示例15: Dispatch
public void Dispatch(SIPEndPoint remoteEndPoint, SIPResponse sipResponse) {
try {
//logger.Debug("Dispatch SIPResponse from " + remoteEndPoint + " " + sipResponse.Header.CSeqMethod + " " + sipResponse.StatusCode + ".");
SIPEndPoint dispatchEndPoint = m_outboundProxy;
if (remoteEndPoint.ToString() == m_outboundProxy.ToString()) {
if (m_callIdEndPoints.ContainsKey(sipResponse.Header.CallId)) {
dispatchEndPoint = SIPEndPoint.ParseSIPEndPoint(m_callIdEndPoints[sipResponse.Header.CallId]);
}
else {
dispatchEndPoint = null;
}
}
if (dispatchEndPoint != null) {
m_sipTransport.SendResponse(dispatchEndPoint, sipResponse);
}
else {
FireProxyLogEvent(new SIPMonitorControlClientEvent(SIPMonitorServerTypesEnum.AppServer, SIPMonitorEventTypesEnum.DialPlan, "The callid for an " + sipResponse.Header.CSeqMethod + " response was not found in the dispatcher callids lookup table, dropping, callid=" + sipResponse.Header.CallId + ".", null));
}
}
catch (Exception excp) {
logger.Error("Exception Dispatch SIPResponse. " + excp.Message);
throw;
}
}