可以集成在一块的。
比如很多 socket,rtmp 等非 HTTP 都能集成的

解决方案 »

  1.   


    我现在在sailfin中部署好了,写了以下代码,doRegister功能正常,可是两台装有sipdroid的手机并不能invite对方,不知道是咋回事
    public class FirstSipServlet extends SipServlet { private static final long serialVersionUID = 1L; SipFactory sf = null;
    ServletContext ctx = null;
    TimerService ts = null; /**
     * _address keeps the mapping between sign-in name and actual contact
     * address.
     */
    protected Map<URI, URI> _addresses = new HashMap<URI, URI>(); /** This is called by the container when starting up the service. */
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    ctx = config.getServletContext();
    sf = (SipFactory) ctx.getAttribute(SipServlet.SIP_FACTORY);
    ts = (TimerService) ctx.getAttribute(SipServlet.TIMER_SERVICE);
    } /** This is called by the container when shutting down the service. */
    public void destroy() {
    try {
    System.out.println("Server is shutting down -- goodbye!");
    } catch (Throwable e) { // ignore all errors when shutting down.
    e.printStackTrace();
    }
    super.destroy();
    } @Override
    protected void doRegister(SipServletRequest req) throws ServletException, IOException {
    System.out.println("doRegister");
    URI toURI = req.getTo().getURI();
    URI fromURI = req.getAddressHeader("Contact").getURI();
    String contact = fromURI.toString();
    contact = contact.substring(0, contact.indexOf(";"));
    fromURI = sf.createURI(contact);
    System.out.println("toURI=" + toURI + ";fromURI=" + fromURI); synchronized (_addresses) {
    if (req.getExpires() != 0) {
    // _addresses.put(AddressOfRecord, Contact);
    _addresses.put(toURI, fromURI);
    } else {
    _addresses.remove(toURI);
    }
    }
    req.createResponse(SipServletResponse.SC_OK).send();
    } @Override
    protected void doInvite(SipServletRequest req) throws ServletException, IOException {
    // Invoked by the server (via the service method) to handle incoming
    // INVITE requests.
    System.out.println("doInvite"); Proxy proxy = req.getProxy(); URI toURI = req.getTo().getURI();
    URI contactURI = req.getAddressHeader("Contact").getURI(); URI contactAddress = null; synchronized (_addresses) {
    contactAddress = _addresses.get(toURI);
    } System.out.println("toURI=" + toURI + ";contactAddress=" + contactAddress + ";contactURI=" + contactURI); // System.out.println("toAddr=" + toAddr + ";contactAddress=" +
    // contactAddress);
    // 根据URI 查询已经注册的用户代理的sip 地址
    if (contactAddress == null) {
    SipServletResponse res = req.createResponse(SipServletResponse.SC_NOT_FOUND);
    System.out.println("contactAddress == null");
    res.send();
    } else {
    proxy.proxyTo(contactAddress);
    }
    }
    }