Exemplo n.º 1
0
  /** 确认会话收到请求 */
  public SipcRequest createAckRequest(String uri) {
    SipcRequest req = this.createDefaultSipcRequest(SipcMethod.ACK);
    req.addHeader(SipcHeader.TO, uri);

    req.setNeedReplyTimes(0);
    return req;
  }
Exemplo n.º 2
0
  /** 开始群会话 */
  public SipcRequest createInviteRequest(String uri, Port localPort) {
    SipcRequest req = this.createDefaultSipcRequest(SipcMethod.INVATE);
    req.addHeader(SipcHeader.TO, uri);
    req.addHeader(SipcHeader.SUPPORTED, "text/html-fragment");
    // req.addHeader(SipcHeader.SUPPORTED, "text/plain");
    req.addHeader(SipcHeader.SUPPORTED, "multiparty");
    req.addHeader(SipcHeader.SUPPORTED, "nudge");
    req.addHeader(SipcHeader.SUPPORTED, "share-background");
    req.addHeader(SipcHeader.SUPPORTED, "fetion-show");

    req.setNeedReplyTimes(2); // 需回复两次

    // 正文是一些固定的参数
    StringBuffer buffer = new StringBuffer();
    buffer.append("v=0\r\n");
    buffer.append("o=-0 0 IN " + localPort.toString() + "\r\n");
    buffer.append("s=session\r\n");
    buffer.append("c=IN IP4 " + localPort.toString() + "\r\n");
    buffer.append("t=0 0\r\n");
    buffer.append("m=message " + Integer.toString(localPort.getPort()) + " sip " + uri);

    req.setBody(new SipcBody(buffer.toString()));

    return req;
  }