快速业务通道

使用SIP Servlet为Java EE添加语音功能 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-16
(to.toString());              registration = em.merge(registration);              em.remove(registration);              utx.commit();              logger.log(Level.FINE, "Registration was successfully created.");          } catch (Exception ex) {              try {                utx.rollback();              } catch (Exception e) {              }          }          em.close();          If the registration is successful , a response code of 200 OK is sent          response.send();      } catch(Exception e) {       If the registration is not successful , a response code of 500 is sent        response.setStatus(500);        response.send();      }    }

使用SIP Servlet为Java EE添加语音功能(5)

时间:2011-07-18 Prasad Subramanian

RegistrationBrowserServlet.java

这是一个 HTTP Servlet,它提供了一个接口,用于列出注册用户并在两个注册用户之间建立呼叫。

@PersistenceContext(name = "persistence/LogicalName", unitName = "EricssonSipPU") public class RegistrationBrowserServlet extends HttpServlet { @PersistenceUnit(unitName = "EricssonSipPU") private EntityManagerFactory emf;   public Collection getRegistrations() {     EntityManager em = emf.createEntityManager();     Query q = em.createQuery("select object(o) from Registration as o");     return q.getResultList();   }   protected void processRequest(HttpServletRequest request, HttpServletResponse response)   throws ServletException, IOException {     response.setContentType("text/html;charset=UTF-8");     PrintWriter out = response.getWriter();      This gets the list of registrations     Collection registrations = getRegistrations();     Iterator iter = registrations.iterator();     out.println("<html><body>");     Call to the HTTP servlet SipCallSetupServlet     out.println("<FORM ACTION = "/CallSetup/SipCallsetupServlet" METHOD = POST>");     out.println("<INPUT TYPE=SUBMIT NAME=Submit VALUE="Submit">");     out.println("</FORM>");     out.println("SipFactoryInstance = "+sf.toString());     out.println("</body></html>");     out.close();   }

SipCallSetupServlet.java

此 HTTP Servlet 通过 RegistrationBrowserServlet 调用,其行为类似于 B2BUA 在两个用户之间建立呼叫。

public class SipCallSetupServlet extends HttpServlet {      SipFactory sf = null;      TimerService ts = null;      ServletContext ctx = null;    public void init(ServletConfig config) throws ServletException {     ctx = config.getServletContext();      Getting the SIpFactory object from the ServletContext     sf = (SipFactory) ctx.getAttribute(SipServlet.SIP_FACTORY);    }    protected void processRequest(HttpSe

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号