如何使用Java在Plivo中创建电话会议?

时间:2014-04-29 14:13:06

标签: java plivo

我已将answer_url添加到具有唯一ID的Conference XML。但我对makecall API的第二次调用收到了IllegalState异常。我不确定我做错了什么?

代码:

LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
params.put("from", "ZZZZZZZZZZZ");
params.put("answer_url",
        "https://dl.dropboxusercontent.com/s/cho3u1633pz43lx/conference.xml");
params.put("callback_method", "GET");

Call response;

String[] conference_numbers = { moderator, participant1 };

try {

    for (int i = 0; i < conference_numbers.length; i++) {
        params.put("to", conference_numbers[i]);
        System.out.println("Number at index " + i + " "
                + conference_numbers[i]);
        response = restAPI.makeCall(params);
        System.out.println(response.apiId);
    }

} catch (PlivoException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
}

控制台:

======= CONSOLE =========================
Moderator Number 1 : XXXXX
Participants Number 1 : YYYYYY
Database connection terminated...!!!
Number at index 0 XXXXX
5304db62-cfa6-11e3-9c37-22000ac7849b
Number at index 1 YYYYYY
Connection manager has been shut down
com.plivo.helper.exception.PlivoException: Connection manager has been shut down
    at com.plivo.helper.api.client.RestAPI.request(RestAPI.java:127)
    at com.plivo.helper.api.client.RestAPI.makeCall(RestAPI.java:238)
    at PlivoConference.main(PlivoConference.java:136)

1 个答案:

答案 0 :(得分:1)

调用restAPI.makeCall关闭连接管理器,restAPI实例变得无法使用。要修复错误,请在每次调用之前创建RestAPI的全新实例。