比如:挂机,拨号,拨外线,保留通话,示闲,示忙等等。。。。

在api中可以获得这些方法说明

/**
  * 给分机挂机
  * @param Extension 要挂机的分机号
  * @return
  * @throws TimeoutException
  * @throws IOException
  * @throws IllegalStateException
  * @throws IllegalArgumentException
  */
 public static ManagerResponse getHangup(String Extension,Integer value) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
   if(BaseUtil.getConnection()==null){
    BaseUtil.getAsteriskJava(); 
   } 
   HangupAction hangupAction=new HangupAction();
   hangupAction.setActionId(BaseController.getactionId("Hangup", Extension));
   hangupAction.setCause(value);//挂机原因 
   hangupAction.setChannel(BaseUtil.getChannel(Extension));
   ManagerResponse response =BaseUtil.getConnection().sendAction(hangupAction);
   return response; 
 }
 /**
  * 分机外呼
  * @param Extension 发起呼叫的分机号
  * @param phone 被呼叫的外线号
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 @SuppressWarnings("deprecation")
 public static ManagerResponse getWOriginate(String Extension,String phone) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
   if(BaseUtil.getConnection()==null){
    BaseUtil.getAsteriskJava();
   }
   OriginateAction origaction=new OriginateAction();
   origaction.setContext("from-internal");//路由器
   String action=BaseController.getactionId("Originate", Extension);
   origaction.setActionId(action);//呼叫action id
   origaction.setChannel("SIP/"+Extension);//呼叫连接通道,呼叫时,先呼通自己
   origaction.setExten("799"+Extension+phone+"#");//要外呼的电话799+分机号是
   origaction.setPriority(1);//优先级
   origaction.setTimeout(20000);//呼叫等待(毫秒)
   origaction.setCallerId(phone);//呼叫号码
   origaction.setAsync(true);//设置异步才会有结果返回
   ManagerResponse response =BaseUtil.getConnection().sendAction(origaction); 
   System.out.println("外呼结果"+response);
   return response;
 }
 
 /**
  * 分机呼分机
  * @param Extension 发起呼叫的分机号
  * @param phone 被呼叫的分机号
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 @SuppressWarnings("deprecation")
 public static ManagerResponse getROriginate(String Extension,String phone) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
   if(BaseUtil.getConnection()==null){
    BaseUtil.getAsteriskJava();
   }
   OriginateAction origaction=new OriginateAction();
   origaction.setContext("from-internal");//路由器
   String action=BaseController.getactionId("Originate", Extension);
   origaction.setActionId(action);//呼叫action id
   origaction.setChannel("SIP/"+Extension);//呼叫连接通道,呼叫时,先呼通自己
   origaction.setExten(phone);//要外呼的电话
   origaction.setPriority(1);//优先级设置1时,不会回拨,为什么
   origaction.setTimeout(20000);//呼叫等待(毫秒)
   origaction.setCallerId(phone);//呼叫号码
   origaction.setAsync(true);//设置异步才会有结果返回
   ManagerResponse response =BaseUtil.getConnection().sendAction(origaction);  
   return response;
 }
 
 /**
  * 插入通话
  * @param Extension 发起呼叫的分机号
  * @param phone 被插入通话的分机号
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 @SuppressWarnings("deprecation")
 public static ManagerResponse getCOriginate(String Extension,String phone) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
   if(BaseUtil.getConnection()==null){
    BaseUtil.getAsteriskJava();
   }
   OriginateAction origaction=new OriginateAction();
   origaction.setContext("spy");//路由器
   String action=BaseController.getactionId("Originate", Extension);
   origaction.setActionId(action);//呼叫action id
   origaction.setChannel("SIP/"+Extension);//呼叫连接通道,呼叫时,先呼通自己
   origaction.setExten("557"+phone);//要插入通话的分机
   origaction.setPriority(1);//优先级
   origaction.setTimeout(20000);//呼叫等待(毫秒)
   origaction.setAsync(true);//设置异步才会有结果返回
   ManagerResponse response =BaseUtil.getConnection().sendAction(origaction);  
   return response;
 }
 /**
  * 监听通话
  * @param Extension 发起监听的分机号
  * @param phone 要监听的分机号
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 @SuppressWarnings("deprecation")
 public static ManagerResponse getJOriginate(String Extension,String phone) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
   if(BaseUtil.getConnection()==null){
    BaseUtil.getAsteriskJava();
   }
   OriginateAction origaction=new OriginateAction();
   origaction.setContext("spy");//路由器
   String action=BaseController.getactionId("Originate", Extension);
   origaction.setActionId(action);//呼叫action id
   origaction.setChannel("SIP/"+Extension);//呼叫连接通道,呼叫时,先呼通自己
   origaction.setExten("556"+phone);//要插入通话的分机
   origaction.setPriority(1);//优先级
   origaction.setTimeout(20000);//呼叫等待(毫秒)
   origaction.setAsync(true);//设置异步才会有结果返回
   ManagerResponse response =BaseUtil.getConnection().sendAction(origaction);  
   return response;
 }
 /**
  * 获取分机状态
  * @param Extension 分机号
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getExtension(String Extension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  ExtensionStateAction extaction=new ExtensionStateAction(Extension,"default");
  
  String Actionid=BaseController.getactionId("Extension", Extension);
  extaction.setActionId(Actionid);
  ManagerResponse response =BaseUtil.getConnection().sendAction(extaction);
  return response;
 }
 /**
  * 获取分机通话的录音文件
  * @param Extension 需要录音的分机号
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getMonitor(String Extension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  MonitorAction MonitorAction=new MonitorAction();   
  MonitorAction.setActionId(BaseController.getactionId("Monitor", Extension));
  MonitorAction.setMix(false);//获取false为1个语音文件,true为两个
  MonitorAction.setChannel(BaseUtil.getChannel(Extension));
  MonitorAction.setFile("分机号:"+Extension+" 时间:"+ToolUtils.formatDate(new Date(), "yyyymmddhhmmss")+" 监听录音");//语音文件的名称
  //MonitorAction.setFormat("");//录音文件编码格式
  ManagerResponse response =BaseUtil.getConnection().sendAction(MonitorAction);
  return response;
 }
 /**
  * 获取所有的sip话机信息连接情况
  * @param Actionid 唯一标识
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getSIPpeers(String Actionid) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  SipPeersAction sippeers=new SipPeersAction();   
  sippeers.setActionId(Actionid);
  ManagerResponse response =BaseUtil.getConnection().sendAction(sippeers);
  return response;
 }
 /**
  * 重定向通话到指定的分机,外线
  * @param outextension 进行指定的本机号
  * @param inextension 指定的分机号,外线
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getRedirect(String outextension,String inextension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  MapCacheUtil mapcache=MapCacheUtil.getInstance();
  String channel=BaseUtil.getChannel(outextension);//获取本机的通道
  RedirectAction redrec=new RedirectAction();
  redrec.setActionId(BaseController.getactionId("Redirect", inextension));
  redrec.setChannel(String.valueOf(mapcache.get(channel)));//要转移的通道
  redrec.setContext("from-internal");
  redrec.setExten(inextension);//要转入的分机
  redrec.setPriority(1);//优先级
  ManagerResponse response=BaseUtil.getConnection().sendAction(redrec);
  return response;
 }
 /**
  * 通话保留
  * @param Extension
  * @param channel 对方通道
  * @param channel2 自己通道
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getPark(String Extension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  MapCacheUtil mapcache=MapCacheUtil.getInstance();
  ParkAction park=new ParkAction();
  String channel=BaseUtil.getChannel(Extension);
  park.setActionId(BaseController.getactionId("Park", Extension));
  park.setChannel(String.valueOf(mapcache.get(channel)));//要保留的通道
  park.setChannel2(channel);//时间结束要返回的通道  
  park.setTimeout(60*60*1000);//保留通话的时间
  ManagerResponse response=BaseUtil.getConnection().sendAction(park);
  return response;
 }
 /**
  * 通话接回
  * @param Extension
  * @param channel 对方通道
  * @param channel2 自己通道
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getBackPark(String Extension,String parked) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  OriginateAction origaction=new OriginateAction();
  origaction.setContext("from-internal");//路由器
  String action=BaseController.getactionId("Originate", Extension);
  origaction.setActionId(action);//呼叫action id
  origaction.setChannel("SIP/"+Extension);//呼叫连接通道,呼叫时,先呼通自己  
  origaction.setExten(parked);
  origaction.setPriority(1);//优先级设置1时,不会回拨,为什么
  origaction.setAsync(true);//设置异步才会有结果返回
  ManagerResponse response =BaseUtil.getConnection().sendAction(origaction);  
  return response;
 }
 /**
  * 桥接通话
  * @param Extension
  * @param channel 对方通道
  * @param channel2 自己通道
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getBridge(String Extension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  MapCacheUtil mapcache=MapCacheUtil.getInstance();
  BridgeAction bridge=new BridgeAction();
  String channel=BaseUtil.getChannel(Extension);
  bridge.setActionId(BaseController.getactionId("Bridge", Extension));
  bridge.setChannel1(String.valueOf(mapcache.get(channel)));
  bridge.setChannel2(channel);
  bridge.setTone(true);
  //park.setTimeout(30000);//保留通话的时间
  ManagerResponse response=BaseUtil.getConnection().sendAction(bridge);
  return response;
 }
 /**
  * 获取分机示忙示闲状态值
  * @param Extension
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse getdatabasednd(String Extension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  DbGetAction db=new DbGetAction();
  db.setActionId(BaseController.getactionId("DND", Extension));
  db.setFamily("DND");
  db.setKey(Extension);
  ManagerResponse response=BaseUtil.getConnection().sendAction(db);
  return response;
 }
 /**
  * 设置分机示闲状态值
  * @param Extension
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse deldatabasednd(String Extension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  DbDelAction db=new DbDelAction();
  db.setActionId(BaseController.getactionId("DND", Extension));
  db.setFamily("DND");
  db.setKey(Extension);
  ManagerResponse response=BaseUtil.getConnection().sendAction(db);
  return response;
 }
 /**
  * 设置分机示忙状态值
  * @param Extension
  * @return
  * @throws IllegalArgumentException
  * @throws IllegalStateException
  * @throws IOException
  * @throws TimeoutException
  */
 public static ManagerResponse setdatabasednd(String Extension) throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException{
  if(BaseUtil.getConnection()==null){
   BaseUtil.getAsteriskJava();
  }
  DbPutAction db=new DbPutAction();
  db.setActionId(BaseController.getactionId("DND", Extension));
  db.setFamily("DND");
  db.setKey(Extension);
  db.setVal("yes");
  ManagerResponse response=BaseUtil.getConnection().sendAction(db);
  return response;
 }

asterisk-java ami4 一些基本功能的例子的更多相关文章

  1. Java 基本数据类型 sizeof 功能

    Java 基本数据类型 sizeof 功能 来源 https://blog.csdn.net/ithomer/article/details/7310008 Java基本数据类型int     32b ...

  2. Java 守护线程(Daemon) 例子

    当我们在Java中创建一个线程,缺省状态下它是一个User线程,如果该线程运行,JVM不会终结该程序.当一个线被标记为守护线程,JVM不会等待其结束,只要所有用户(User)线程都结束,JVM将终结程 ...

  3. java 多线程——quartz 定时调度的例子

    java 多线程 目录: Java 多线程——基础知识 Java 多线程 —— synchronized关键字 java 多线程——一个定时调度的例子 java 多线程——quartz 定时调度的例子 ...

  4. java 多线程——一个定时调度的例子

    java 多线程 目录: Java 多线程——基础知识 Java 多线程 —— synchronized关键字 java 多线程——一个定时调度的例子 java 多线程——quartz 定时调度的例子 ...

  5. java操作xml的一个小例子

    最近两天公司事比较多,这两天自己主要跟xml打交道,今天更一下用java操作xml的一个小例子. 原来自己操作xml一直用这个包:xstream-1.4.2.jar.然后用注解的方式,很方便,自己只要 ...

  6. Java编程思想-注解生成外部例子代码

    如果本文帮助到您,请点击下面的链接,这是本人的网站,以示鼓励,谢谢!链接绝对安全! 本人的网站 java注解属于java中高大上的功能,许多开源框架都使用了java注解的功能.比如spring,hib ...

  7. java 三次样条插值 画光滑曲线 例子

    java 三次样条插值 画光滑曲线 例子 主要是做数值拟合,根据sin函数采点,取得数据后在java中插值并在swing中画出曲线,下面为截图  不光滑和光滑曲线前后对比:    代码: 执行类: p ...

  8. Java实现发邮件功能---网易邮箱

    目录 Java实现发邮件功能 前言 开发环境 代码 效果 结束语 Java实现发邮件功能 前言 电子邮件的应用场景非常广泛,例如新用户加入,即时发送优惠清单.通过邮件找回密码.监听后台程序,出现异常自 ...

  9. Java中连接MySql数据库的例子

    Java中连接MySql数据库的例子: package com.joinmysql.demo; import java.sql.DriverManager; import java.sql.Resul ...

随机推荐

  1. select case when if

    select case when if 的一些用法 - 马丁传奇 - 博客园 https://www.cnblogs.com/martinzhang/p/3220595.html Write a SQ ...

  2. LeetCode 1.两数之和(JS)

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...

  3. caioj1270: 概率期望值1:小象涂色

    DP深似海,得其得天下.——题记 叕叕叕叕叕叕叕叕叕叕叕(第∞次学DP内容)被D飞了,真的被DP(pa)了.这次D我的是大叫着第二题比较难(小象涂色傻b题)的Mocha(zzz)大佬,表示搞个概率DP ...

  4. HDU1260 Tickets —— DP

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1260 Tickets Time Limit: 2000/1000 MS (Java/Oth ...

  5. iOS7 push/pop转场动画

    前言 iOS 7之后,苹果提供了自定义转场动画的API,我们可以自己去定义任意动画效果.本篇为笔者学习push.pop自定义转场效果的笔记,如何有任何不正确或者有指导意见的,请在评论中留下您的宝贵意见 ...

  6. 深入理解JMM(Java内存模型) --(一)

    并发编程模型的分类 在并发编程中,我们需要处理两个关键问题:线程之间如何通信及线程之间如何同步(这里的线程是指并发执行的活动实体).通信是指线程之间以何种机制来交换信息.在命令式编程中,线程之间的通信 ...

  7. MVC视图中下拉框的使用

    一.一般变量或对象的绑定 首先要在controller 中将选项设置成 selecList对象,并赋值给viewBag动态对象. public ActionResult Index(string mo ...

  8. springMVC访问根路径问题

    当web.xml没有配置欢迎页:如下 <welcome-file-list> <welcome-file>login.jsp</welcome-file> < ...

  9. Educational Codeforces Round 14E. Xor-sequences(矩阵快速幂)

    传送门 题意 给定序列,从序列中选择k(1≤k≤1e18)个数(可以重复选择),使得得到的排列满足\(x_i与x_{i+1}\)异或的二进制表示中1的个数是3的倍数.问长度为k的满足条件的序列有多少种 ...

  10. bzoj 3218: a + b Problem【主席树+最小割】

    直接建图比较显然,是(s,i,w),(i,t,b),(i,i',p),(i,j,inf),然而建出来之后发现边数是n方级别的,显然跑不过去,然后就有一种比较神的思路:把a离散了建一棵权值线段树,然后要 ...