【问题标题】:How to check if a custom header exists on a message using a MSPL script如何使用 MSPL 脚本检查消息中是否存在自定义标头
【发布时间】:2017-09-08 09:37:46
【问题描述】:

我正在使用以下 MSPL 脚本将音频呼叫定向到 UCMA 应用程序。

<?xml version="1.0" encoding="utf-8"?>
<r:applicationManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" r:appUri="http://www.example.com/recording" xmlns:r="http://schemas.microsoft.com/lcs/2006/05">
  <r:requestFilter methodNames="ALL" strictRoute="true" registrarGenerated="true" domainSupported="true" />
  <r:allowRegistrationBeforeUserServices action="true" />
  <r:responseFilter reasonCodes="NONE" />
  <r:proxyByDefault action="true" />
  <r:scriptOnly />
  <r:splScript><![CDATA[ 
            /* 
                This script has been generated by SimpleRoute. Changes to this file may cause unexpected behavior.
                -
                -
                -
                All audio calls from any origin
                are redirected to 'recording@example.com'!
            */

            function InviteHasBody()
            {
                foreach(header in GetHeaderValues(StandardHeader.ContentType))
                {
                    /* Found a content-type header, so we know it has a body. */
                    return true;
                }
                return false;
            }

            function IsAudioCall()
            {
                if((sipRequest.Method == "INVITE") && (!InviteHasBody() || ContainsString(sipRequest.Content,"\nm=audio ", false) || ContainsString(sipRequest.Content,"\rm=audio ", false)))
                {
                    return true;
                }
                return false;
            }

            function IgnoreCall()
            {
                foreach(header in GetHeaderValues("IgnoreCall"))
                {
                    /* Found ignore call. */
                    return true;
                }
                return false;
            }

            if (sipRequest)
            {
                if(IsAudioCall())
                {
                    if (!IgnoreCall())
                    {
                        targetUser = "sip:recording@example.com";
                        userAtHost =  GetUserAtHost(targetUser);
                        targetRequestUri = "";
                        foreach(dbEndpoint in QueryEndpoints(userAtHost, true))
                        {
                            targetEpid = dbEndpoint.EPID;
                            targetRequestUri = dbEndpoint.ContactInfo;
                            if(targetRequestUri != "" && targetRequestUri != null)
                                break;
                        }

                        if(targetRequestUri == "")
                        {
                            RetargetRequest("sip:recording@example.com");
                            return;
                        }
                        ProxyRequest(targetRequestUri);
                    }
                }
            }
]]></r:splScript>
</r:applicationManifest>

问题是 UCMA 应用收到来电,与受信任的参与者创建会议(因此可以记录),然后呼叫第二站并将呼叫加入会议。问题部分是调用第二条腿,因为它被 MSPL 脚本拾取,并且呼叫被定向到 UCMA 应用程序。这会导致错误提示

对于带有路由标头的请求,分叉无效

当进行 2 条腿调用时,我使用下面的代码添加了一个名为 IgnoreCall 的自定义标题。

McuDialOutOptions mcuDialOutOptions = new McuDialOutOptions();
mcuDialOutOptions.ParticipantUri = destinationUri;
mcuDialOutOptions.Headers.Add(new SignalingHeader("IgnoreCall", "true"));
_incomingAudioVideoCall.Conversation.ConferenceSession.AudioVideoMcuSession.DialOutAsync(destinationUri, mcuDialOutOptions);

这样 MSPL 脚本可以检查调用是否应定向到 UCMA 应用程序。但 MSPL 脚本未检测到消息/调用具有 IgnoreCall 标头。

谁能告诉我检查消息/呼叫是否包含名为 IgnoreCall 的标头以便我知道何时不将消息/呼叫定向到 UCMA 应用程序的最佳方法是什么?

【问题讨论】:

    标签: lync skype-for-business ucma


    【解决方案1】:

    您的代码对我来说看起来不错,我会尝试确定来自会议服务器的新 INVITE 是否具有标头。

    您可以: * 使用Skype logging 来检查INVITE 是否有例外的标头。如果不是,则说明 DialOutAsync 不正确。不知道我能帮上忙。 * 您可以使用 MSPL Log 命令“记录”调试信息以查看您的 MSPL 脚本的运行情况。

    一些小的 MSPL 注释:

    您不需要调用“ProxyRequest”。如果请求没有被重新定位或已经被代理,默认情况下它会这样做。

    我不确定你在用“QueryEndpoints”调用做什么,它看起来你什么都不做,所以我会删除它。

    我会将支持的方法限制为“INVITE”,因为您不想重定向其他请求类型。 例如

    我只会重定向邀请而不是重新邀请。所以你需要检查 To 标头是否有“tag”参数。 例如

    toTag = GetParameterValue(sipRequest.To, "tag");
    if (toTag != null) {
        // This is a re-INVITE.
        return;
    }
    

    无论如何,您都应该过滤掉任何已经前往您的重定向目标的 INVITE...

    另一个选项是您可以过滤掉电话会议的任何来电。 例如从会议服务器:

    opaqueTag = GetParameterValue(sipRequest.From, "opaque");
    if (opaqueTag != null && ContainsString(opaqueTag, "app:conf:")) {
        // This is a conference call.
        return;
    }
    

    您应该能够找出 To 会议服务器呼叫。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-05
      • 2012-10-17
      • 2021-04-18
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多