I am programing an IVR application by using Asterisk version 13.11.0~dfsg-0~ppa3 and ari4java verison 0.4.2.
I’ve found that, the ARI interface for setting channel variable has a little bit delay utill it takes effect. For example, I set channel language to german and play announcement in onSuccess() callback, but sometimes the announcement is still played in original language, and sometimes does palyed in target langauge.
Please see my example code below:
private void setChannelLanguage(String channelId, String targetLan) {
ari.channels().setChannelVar(channelId, "CHANNEL(language)", targetLan, new AriCallback<Void>() {
@Override
public void onSuccess(Void result) {
log.info("CHANNEL(language) should be switched to " + targetLan);
//Announcement is played sometimes still in original language!
playAnnouncement();
}
@Override
public void onFailure(RestException e) {
log.error("SetChannelVar: " + e.getLocalizedMessage());
}
});
}
If I apply a sleep of 200 ms on the thread before playAnnouncement(), then the announcement will be always played in target language.
Any ideal?