HttpSessionßàSipSession
(1)HttpSessionàSipSession的方法:
import javax.servlet.sip.ConvergedHttpSession;
import javax.servlet.sip.SipApplicationSession;
import javax.servlet.sip.SipSession;
ConvergedHttpSession chs = (ConvergedHttpSession) httpReq.getSession();
SipApplicationSession sas = chs.getApplicationSession();
Iterator sipSessions = sas.getSessions("SIP");
(2)HttpSessionßSipSession的方法:
目前,还没有找到明确讲解SipSessionàHttpSession的理论方法或示例代码。是不是可以这样:如果已知某SipApplicationSession是converged的,则执行以下代码找到HTTP Session。
个人想法。
SipSession ss = sipReq.getSession();
SipApplicationSession sas = ss.getApplicationSession();
Iterator httpSessions = sas.getSessions("HTTP");
use case
举例的聚合应用包含一个HTTP Servlet(ClickToDialServlet)和一个SIP Servlet(CallServlet),下面主要针对HTTP Servlet进行说明,因为它与ConvergedHttpSession的使用相关。
ClickToDialServlet允许初始化和结束一个SIP呼叫。示例代码如下:
@Resource(mappedName = "sip/convergedapp")
private SipFactory sipFactory;
public class ClickToDialServlet extends HttpServlet {
public void doGet(HttpServletRequest httpReq, HttpServletResponse httpRes)
throws ServletException, IOException {
// 初始化或结束一个SIP呼叫,取决于请求参数"action"的值
String action = httpReq.getParameter("action");
if (action.equals("call")) {
initiateSipCall(httpReq, httpRes);
} else if (action.equals("bye")) {
terminateSipCall(httpReq, httpRes);
} else {
throw new ServletException("Invalid action");
}
}
[...]
}
/**
* 初始化一个SIP call
*/
private void initiateSipCall(HttpServletRequest httpReq, HttpServletResponse httpRes) throws ServletException, IOException {
// 由一个HTTP请求生成一个新的ConvergedHttpSession
ConvergedHttpSession chs = (ConvergedHttpSession) httpReq.getSession();
// 由ConvergedHttpSession生成一个新的SipApplicationSession,并将二者关联起来。
SipApplicationSession sas = chs.getApplicationSession();
// 生成SIP URI
String localIp = InetAddress.getLocalHost().getAddress().toString();
Address fromAddr = sipFactory.createAddress("sip:foo@" + localIp + ":" + System.getProperty("SIP_PORT"));
Address toAddr = sipFactory.createAddress("sip:bar@" + httpReq.getParameter("remoteIp") + ":" + httpReq.getParameter("remotePort"));
// 生成SIP INVITE请求,此处请求是与SipApplicationSession相关的。
SipServletRequest sipReq = sipFactory.createRequest(sas, "INVITE", fromAddr, toAddr);
// 由SIP请求生成一个SipSession
SipSession sipSession = sipReq.getSession();
// 所有与新的SipSession相关的请求和响应都将交由聚合应用的CallServlet来处理
sipSession.setHandler("CallServlet");
// 将SipSession的id作为一个session属性"CallId"存储到SipApplicationSession中,从而保证稍后可以找到SipSession,结束呼叫。
sas.setAttribute("CallId", sipSession.getId());
// 发送请求
sipReq.send();
// 返回一个用于结束呼叫的web form
PrintWriter out = httpRes.getWriter();
out.println("<form action=\"ClickToDialServlet\" method=\"GET\">");
out.println("<input type=\"hidden\" name=\"action\" value=\"bye\"/>");
out.println("<input type=\"submit\" value=\"Terminate call\"/>");
out.println("</form>");
}
/**
* 结束一个SIP call.
*/
private void terminateSipCall(HttpServletRequest httpReq, HttpServletResponse httpRes) throws ServletException, IOException {
// 维护ConvergedHttpSession,根据与请求一起发送的JSESSIONID cookie进行识别
ConvergedHttpSession chs = (ConvergedHttpSession) httpReq.getSession(false);
// 得到SipApplicationSession
SipApplicationSession sas = chs.getApplicationSession();
// 得到"CallId"属性对应的SipSession
SipSession sipSession = sas.getSipSession((String) sas.getAttribute("CallId"));
// 发送BYE请求结束呼叫
sipSession.createRequest("BYE").send();
}
参考:http://blogs.sun.com/jluehe/entry/converged_http_sessions_in_sailfin
分享到:
相关推荐
This test document specifies test methodologies and performance criteria for the RF performance evaluation of WiFi mobile converged devices. The scope of testing includes Handheld, self-contained Wi-...
IMS Multimedia Telephony over Cellular Systems-VoIP Evolution in a Converged Telecommunication World Wiley 2007.rar
The present document is structured in the same manner as TS 181 005 [3] and the main clause numbering from this point in the document onwards therefore follows that document, with the scope of those ...
Lenovo Converged HX Series 是联想推出的一系列融合基础设施解决方案,旨在帮助企业简化IT基础设施管理,降低成本,并提高运营效率。这些设备集成了计算、存储、网络和管理功能,以提供一个全面的、易于使用的数据...
Converged HX Series Competitive-All.pdf
abaqus Abaqus收敛培训教材Obtaining a Converged Solution with AbaqusC 2021 pdf
in which the techniques of cooperative communication and wireless relay are utilized to improve performances of the individual user and the overall converged networks. In order to evaluate the ...
本文介绍的是Nortel Converged Office for Communication Server 1000白皮书(英文).
A unified protocol stack solutionfor LTE and WLAN in future mobile converged networks
本文介绍的是Nortel Converged Office for Communication Server 1000使用手册(英文).
vmware VSP HCI (2020) - Hyper-Converged Intrastructure Assessment 考试题库
驱动 HP NC553i 10Gb 2-port FlexFabric Converged Network Adapter,2008 r2
4.error:divergence detected in AMG solver 5.error:temperature divergence detected in AMG solver 6.turbulent viscosity limited to viscosity ratio of 1.000000e+5 in 7.error:floating point error:...
A new metasurface design is used to generate the vortex beam, in which the required accumulated phase difference along the propagation path is realized by designing and arranging artificial single-...
"藏经阁-How Spark is Enabling the New Wave of Converged Applications" Spark 是一种基于内存的数据处理引擎,它可以使得数据处理速度大幅提升,并且支持实时数据处理和批量数据处理。Spark 的出现使得新一代...
This is a collaborative development effort from Cisco system and Rockwell Automation. It is built on and adds to, design guidelines from the Cisco Ethernet-to-the-Factory (EttF) solution and the ...
iNOF,即智能网络优化功能,是华为推出的一种创新技术,结合了RoCE(RDMA over Converged Ethernet,远程直接内存访问通过融合以太网)和SAN(存储区域网络)的优势,旨在解决传统金融业务中的存储效率和稳定性问题...
IBM 3758-L32是一种架顶式FCoE交换机,带有24个用于连接LAN的万兆以太网端口和8个用于连接光纤通道SAN的光纤通道端口(最高速度达8 Gbps)。这种可靠的高性能交换机可提供先进的光纤通道服务并支持CEE功能,由DCFM...
• Support added for TerraStar-C correction data which enables better converged accuracy and faster re-convergence • Steadyline now provides smooth transitions, between solution types in BESTPOS, ...
E6000:trade_mark:融合边缘路由器(CER)继承了C4 CMTS的高度成功的传统,并以简单,强大的集成架构为高密度市场提供了更高水平的密度和成本效益。