Asterisk PAMI QueueStatus Action不返回队列名称,我该如何使用Asterisk AMI Action获取队列名称?
创始人
2024-09-20 20:00:47
0

要获取队列名称,您可以使用Asterisk AMI的QueueSummary Action。这个Action将返回有关队列的详细信息,包括队列名称。

以下是一个使用Asterisk AMI Action获取队列名称的示例代码:

import java.io.IOException;
import org.apache.commons.net.telnet.TelnetClient;

public class AsteriskAMITest {

    public static void main(String[] args) {
        TelnetClient tc = new TelnetClient();

        try {
            tc.connect("localhost", 5038);
            String response = readResponse(tc);
            System.out.println(response);

            String action = "Action: QueueSummary\r\n";
            String actionId = "ActionID: 1\r\n";
            String actionCommand = action + actionId + "\r\n";
            sendCommand(tc, actionCommand);

            response = readResponse(tc);
            System.out.println(response);

            tc.disconnect();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static String readResponse(TelnetClient tc) throws IOException {
        StringBuilder sb = new StringBuilder();
        char[] buffer = new char[1024];
        int bytesRead;
        do {
            bytesRead = tc.getInputStream().read(buffer);
            sb.append(buffer, 0, bytesRead);
        } while (bytesRead == buffer.length);
        return sb.toString();
    }

    private static void sendCommand(TelnetClient tc, String command) throws IOException {
        tc.getOutputStream().write(command.getBytes());
        tc.getOutputStream().flush();
    }

}

在上面的代码中,我们创建了一个TelnetClient对象来连接到Asterisk AMI接口。然后,我们发送QueueSummary Action来获取有关队列的详细信息。最后,我们读取和打印服务器的响应。

请注意,您需要将localhost替换为您的Asterisk服务器的IP地址,并根据需要更改端口号(默认为5038)。

希望这可以帮助您解决问题!

相关内容

热门资讯

外挂绝活!uupoker透视,... 外挂绝活!uupoker透视,扑克之星辅助-总是是真的有辅助教程(哔哩哔哩)1、点击下载安装,扑克之...
外挂妙计!智星菠萝可以辅助吗,... 外挂妙计!智星菠萝可以辅助吗,佛手在线大菠萝为什么都输-一贯真的是有辅助方法(哔哩哔哩)1、下载好佛...
外挂攻略!来玩app 德州 辅... 外挂攻略!来玩app 德州 辅助,约局吧如何查看是否有挂-果然一直总是有辅助方法(哔哩哔哩)1、每一...
外挂烘培!sohoo辅助,po... 外挂烘培!sohoo辅助,pokeplus脚本-真是有辅助教程(哔哩哔哩)一、pokeplus脚本可...
外挂大纲!大菠萝免费辅助,哈糖... 外挂大纲!大菠萝免费辅助,哈糖大菠萝软件下载-切实存在有辅助工具(哔哩哔哩)1、哈糖大菠萝软件下载透...
外挂教程书!聚星ai辅助工具激... 外挂教程书!聚星ai辅助工具激活码,德普之星透视辅助软件激活码-原来有辅助技巧(哔哩哔哩)1、很好的...
外挂资料!佛手大菠萝有挂吗,拱... 外挂资料!佛手大菠萝有挂吗,拱趴大菠萝万能挂-竟然一直总是有辅助脚本(哔哩哔哩)1、超多福利:超高返...
外挂攻略!aa poker辅助... 外挂攻略!aa poker辅助,德州局透视-原来是真的有辅助教程(哔哩哔哩)1、许多玩家不知道德州局...
外挂手筋!德州局脚本,poke... 外挂手筋!德州局脚本,pokemomo辅助工具-原来是有辅助脚本(哔哩哔哩)1、玩家可以在pokem...
外挂办法!pokermaste... 外挂办法!pokermaster辅助器,pokerworld修改器-好像是真的有辅助方法(哔哩哔哩)...