예제 #1
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;
  }
예제 #2
0
  public SipcReceipt createHttpInviteReceipt(
      String uri, String callId, String sequence, Port local) {
    SipcReceipt receipt = this.createDefaultReceipt(callId, sequence);
    receipt.addHeader(SipcHeader.FROM, uri);
    receipt.addHeader(SipcHeader.SUPPORTED, "text/html-fragment");
    receipt.addHeader(SipcHeader.SUPPORTED, "text/plain");
    // receipt.addHeader(SipcHeader.SUPPORTED,"multiparty");
    // receipt.addHeader(SipcHeader.SUPPORTED,"nudge");
    // receipt.addHeader(SipcHeader.SUPPORTED,"share-background");
    // receipt.addHeader(SipcHeader.SUPPORTED,"fetion-show");

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

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

    return receipt;
  }