繁体   English   中英

在 ari-client ChannelDtmfReceived 中接收 10 个继续按键

[英]receive 10 continue press key together in ari-client ChannelDtmfReceived

如何接收用户在电话中按下的 10 位数字。 我正在使用 nodejs 的“ari-client”模块

client.on( 'StasisStart', function (event, channel) {
    channel.answer(
        function (err) {
            if (err) {
                logger.error(err);
            }
            channel.play({media: 'sound:priv-callee-options'}, playback, function (err, playback) {
                if(err){
                    return logger.error(err);
                }
            });
            channel.on('ChannelDtmfReceived', function (event, channel) {
            var digitPressed = event.digit;
            if(digitPressed==1234567890){
                client.channels.hold(
                  {channelId: channel.id},
                  function (err) {
                    console.log("Phone On Hold..");
                  }
                );
            }
          });
       });
    });

使用应用程序阅读

pro-sip*CLI> core show application Read

  -= Info about application 'Read' =- 

[Synopsis]
Read a variable. 

[Description]
Reads a #-terminated string of digits a certain number of times from the user
in to the given <variable>.
This application sets the following channel variable upon completion:
${READSTATUS}: This is the status of the read operation.
    OK
    ERROR
    HANGUP
    INTERRUPTED
    SKIPPED
    TIMEOUT

[Syntax]
Read(variable[,filename[&filename2[&...]][,maxdigits[,options[,attempts[,timeout]]]]])

[Arguments]
variable
    The input digits will be stored in the given <variable> name.
filename
    file(s) to play before reading digits or tone with option i
maxdigits
    Maximum acceptable number of digits. Stops reading after <maxdigits>
    have been entered (without requiring the user to press the '#' key).
    Defaults to '0' - no limit - wait for the user press the '#' key.
    Any value below '0' means the same. Max accepted value is '255'.
options
    s: to return immediately if the line is not up.

    i: to play  filename as an indication tone from your "indication
    s.conf".

    n: to read digits even if the line is not up.

attempts
    If greater than '1', that many <attempts> will be made in the event
    no data is entered.
timeout
    The number of seconds to wait for a digit response. If greater than
    '0', that value will override the default timeout. Can be floating
    point.

[See Also]
SendDTMF()
pro-sip*CLI> 

我写了一个库来复制 READ 拨号方案应用程序

https://www.npmjs.com/package/ari-read

应该可以帮助你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM