如何为从ESL执行的应用程序设置Application-UUID

时间:2017-04-06 10:59:23

标签: freeswitch

我想知道每个CHANNEL_EXECUTE事件触发的ExecuteApplication调用。在Managed ESL的ExecuteAsync方法中,没有支持此参数的参数。签名是:

public ESLevent ExecuteAsync(string app, string arg, string uuid)

当使用此ExecuteAsync启动应用程序时,FreeSwitch会为应用程序生成UUID,这将在随后的所有CHANNEL_EXECUTE事件的Application-UUID标头字段中显示。问题是ExecuteAsynch调用没有返回此UUID。如果有多个正在运行的应用程序,这使得跟踪CHANNEL_EXECUTE事件变得棘手。 ExecuteAsynch返回的事件具有以下形式(不存在UUID):

{  
    "Event-Name": "SOCKET_DATA",
    "Content-Type": "command/reply",
    "Reply-Text": "+OK"
}

例如,使用Bgapi执行API调用支持job_uuid参数,该参数将是相关BACKGROUND_JOB事件的Job-UUID标头字段的值。

 public ESLevent Bgapi(string cmd, string arg, string job_uuid)

如何为播放等拨号方案应用程序实现相同的目标?

我已经检查过它是否被Managed Wrapper隐藏了,但是esl.c中的esl_execute函数(包装器的ExecuteAsync方法使用它)似乎也不支持这个:< / p>

ESL_DECLARE(esl_status_t) esl_execute(esl_handle_t *handle, const char *app, const char *arg, const char *uuid)

1 个答案:

答案 0 :(得分:0)

根据documentation of sendmsg.state('income', { url: '/income', parent: 'root', views: { 'main@': 'pageContent' }, ... 标头值是为此目的而设计的。 API中的Event-UUID函数使用esl_execute发送自编esl_send_recv条消息,但不幸的是它没有提供设置此字段的方法。 一种方法是撰写包含sendmsg字段的类似sendmsg消息,并通过Event-UUID发送。

例如使用Managed ESL:

esl_send_recv

因此要发送的消息将具有以下形式:

public void ExecuteApplication(ESLconnection conn, string application, string appParams, string uiid, string jobid)
{
    var header = new Dictionary<string, string>
    {
        {"call-command", "execute"},
        {"execute-app-name", application },
        {"execute-app-arg", appParams },
        {"loops", "1" },
        {"Event-UUID", jobid },
    };
    string newLine = "\n";
    var cmd = $"sendmsg {uiid}{newLine}" + string.Join(newLine, header.Select(kvp => $"{kvp.Key}: {kvp.Value}"));
    var e = conn.SendRecv(cmd);
    ...
}
相关问题