Sailfin自带的例子CallSetup的实现过程

1. 首先,UAC(可以是X-lite等)向RegistrarServlet注册,RegistrarServlet继承SipServlet,doRegister(SipServletRequest request)对注册请求进行出来,其间,会对expires头进行判断请求是否过期,如果获得contact头,则response会发送200 ok给contact头,否则会发给from头,最后持久化to ,contact, expires到Registration。

2. 注册完后,用户通过浏览器即可浏览已经注册的信息,ListWebServlet负责显示所有注册的用户信息,它继承自HttpServlet,通过持久层获得所有注册信息然后现实在页面上。

3. 任意选择两个注册的用户来作为呼叫双方,发送请求消息,B2BCallServlet处理请求,进行双方的呼叫建立。方法如下,此处sip结合在httpservlet里了:
SipApplicationSession as = sf.createApplicationSession();
          //Just to make it simpler to understand 0 will be called A 1 B
          String callA = registrations.get(0).getContact();
          String callB = registrations.get(1).getContact();
         
          Address to = sf.createAddress(callB);
          Address from = sf.createAddress(callA);
         
          SipServletRequest sipReq = sf.createRequest(as, "INVITE", from, to);

         logger.log(Level.FINE, "ListWebServlet sipRequest = " + sipReq.toString());
         sipReq.setAttribute("CALL","INITIAL");
        
         // set servlet to invoke by reponse
         SipSession s = sipReq.getSession();
         s.setHandler("b2b");

4. B2BCallServlet的doRequest(SipServletRequest req)处理接收到的请求

你可能感兴趣的:(浏览器,servlet)