70 likes | 83 Views
Hints for the project. Client. Client. Client. CSCF. HTTP Servlet. Client. Conference Sip Servlet. HSS. CSCF. Client. Client. start. startConf(participantsList). Invite. Invite. Ok. Ok. Ack. Ack. endConf(). end. What to implement?. (user profile). Application Sever. Invite.
E N D
Client Client Client CSCF HTTP Servlet Client Conference Sip Servlet HSS CSCF Client Client start startConf(participantsList) Invite Invite Ok Ok Ack Ack endConf() end What to implement? (user profile) Application Sever Invite Invite Conference application
Communication between HTTP Sevlet & SIP Servlet Field name: ‘name’ • web.xml <listener> <listener-class> ConferenceSipServlet</listener-class> <listener> • HTTP Servlet: private void processRequest (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ……………………… // if start button was clicked { String name = request.getParameter(“name"); context.setAttribute(“Name", name); } ………….. } name start
Communication between HTTP Sevlet & SIP Servlet Installation of SDS • Conference SIP Servlet: public class ConferenceSipServlet extends SipServlet implements ServletContextAttributeListener { static ServletContext context; ………….. public void attributeAdded(ServletContextAttributeEvent attrEv) { handleTrigger(attrEv); } public void attributeReplaced(ServletContextAttributeEvent attrEv) { handleTrigger(attrEv); } handleTrigger(attrEv){ if (attrEv.getName().equalsIgnoreCase(“Name")) { String name = (String) attrEv.getValue(); …………………….. } }
Installation of SDS Media Handling
HTTP Servlet example Installation of SDS privatevoid processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String action = request.getParameter("action"); if (action != null && action.length() != 0) { if ((action.equals("start"))) // if start button was clicked { String name = request.getParameter("name"); context.setAttribute("Name", name); } else { System.out.println("\n\n\n action=" + action + " not recognized"); } return; } response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title> My HTTP Servlet</title>"); out.println("</head>"); out.println("<body>"); out.println("<FORM ACTION = \"MyHTTPServlet\" METHOD = POST>"); import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; publicclass MyHTTPServlet extends javax.servlet.http.HttpServlet Implements javax.servlet.Servlet { staticfinallongserialVersionUID = 1L; boolean targetInitialized = false; static ServletContext context; /* * (non-Java-doc) * * @see javax.servlet.http.HttpServlet#HttpServlet() */ publicvoid init(ServletConfig config) throws ServletException { super.init(config); context = config.getServletContext(); } public MyHTTPServlet() { super(); }
HTTP Servlet example Installation of SDS out.println("Name <input type=\"text\" size=\"10\" maxlength=\"40\" name=\"name\" value=\"nameTest\"> <br />"); out.println("<br/>"); out.println("<input type=\"hidden\" name=\"action\" value=\"start\"/>"); out.println("<INPUT TYPE=SUBMIT NAME=Submit VALUE=\"Start\">"); out.println("</FORM>"); out.println("</body>"); out.println("</html>"); out.close(); }// end processRequest protectedvoid doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } protectedvoid doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } public String getServletInfo() { returnsuper.getServletInfo(); } } //end MyHTTPServlet