使用SIP Servlet为Java EE添加语音功能 - 编程入门网
rvletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String callA = null;
String callB = null;
Getting the contacts from request parameters
String[] contacts = request.getParameterValues("CONTACT");
if ( contacts.length < 2 ) {
return;
}
callA = contacts[0];
callB = contacts[1];
Using the SipFactory object to create a SipApplicationSession
SipApplicationSession as = sf.createApplicationSession();
Using the SipFactory object to create a "To" and "From" Address objects
Address to = sf.createAddress(callB);
Address from = sf.createAddress(callA);
Creating a SipServletRequest using the SipFactory and the SipApplicationSessionObjects created. Note that
INVITE is being sent as if UserA is inviting UserB.
SipServletRequest sipReq = sf.createRequest(as, "INVITE", from, to);
logger.log(Level.FINE, "SipCallSetupServlet sipRequest = " + sipReq.toString());
Set an attribute in SipServletRequest to indicate that this is an initial INVITE
sipReq.setAttribute("CALL","INITIAL");
// set servlet to invoke by response
Getting a SipSession from the Request created
SipSession s = sipReq.getSession();
This is the key part. We set name of the servlet that would handler the response for the
Request being sent. Here b2b is the name of the SIP Servlet that would handle the response
to this request.
s.setHandler("b2b");
// lets send invite to B ...
Sending the request
sipReq.send();
}
使用SIP Servlet为Java EE添加语音功能(6)时间:2011-07-18 Prasad SubramanianB2BCallServlet.java 这个 SIP Servlet 接收并处理针对 SipCallSetupServlet 发送的 INVITE 请求的响应。该 servlet 处理响应头部和正文,获取 SDP,并 向其他用户代理发送另一个 INVITE 请求和 SDP 元数据。接收到来自其他用户的带有成功响应代码的响应之后,该 servlet 在两个用户之间 建立呼叫。
|
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |