我已经实现了一个 Java 方法(使用 Asterisk-Java 库)来启动两个用户之间的调用。Alice 是呼叫者,而 Bob 是接收者。它有效,但我不知道为什么,它分两步完成:
- 爱丽丝接到她自己的电话。
- 如果 Alice 接听电话,那么她和 Bob 之间的通话就会启动。(= Alice 必须点击“Accept the call”,以便最终拨打 Bob。
知道为什么爱丽丝会先接到自己的电话吗?
这是我的代码:
public void call(final String user, final String exten) throws IOException, AuthenticationFailedException, TimeoutException {
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setChannel("SIP/" + user);
originateAction.setContext("work");
originateAction.setExten(exten);
originateAction.setPriority(new Integer(1));
originateAction.setTimeout(new Long(30000));
// connect to Asterisk and log in
managerConnection.login();
// send the originate action and wait for a maximum of 30 seconds for Asterisk to send a reply
originateResponse = managerConnection.sendAction(originateAction, 30000);
// and finally log off and disconnect
managerConnection.logoff();
}