Package net.solosky.maplefetion.sipc

Examples of net.solosky.maplefetion.sipc.SipcRequest


    /**
     * 获取群列表
     */
    public SipcRequest createGetGroupListRequest(int localVersion)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.SERVICE);
      req.addHeader(SipcHeader.EVENT, "PGGetGroupList");
     
      req.setBody(new SipcBody(MessageTemplate.TMPL_GET_GROUP_LIST.replace("{version}", Integer.toString(localVersion))));
     
      return req;
    }
View Full Code Here


    /**
     * 获取群信息
     */
    public SipcRequest createGetGroupInfoRequest(Collection<Group> groupList)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.SERVICE);
      req.addHeader(SipcHeader.EVENT, "PGGetGroupInfo");
     
      Iterator<Group> it = groupList.iterator();
      StringBuffer buffer = new StringBuffer();
      String node = "<group uri=\"{uri}\" />";
      while(it.hasNext()){
        buffer.append(node.replace("{uri}", it.next().getUri()));
      }
     
      req.setBody(new SipcBody(MessageTemplate.TMPL_GET_GROUP_INFO.replace("{groupList}", buffer.toString())));
     
      return req;
    }
View Full Code Here

    /**
     * 获取群成员列表
     */
    public SipcRequest createGetMemberListRequest(Collection<Group> groupList)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.SERVICE);
      req.addHeader(SipcHeader.EVENT, "PGGetGroupMembers");
     
      Iterator<Group> it = groupList.iterator();
      StringBuffer buffer = new StringBuffer();
      String node = "<group uri=\"{uri}\" />";
      while(it.hasNext()){
        buffer.append(node.replace("{uri}", it.next().getUri()));
      }
     
      req.setBody(new SipcBody(MessageTemplate.TMPL_GET_MEMBER_LIST.replace("{groupList}", buffer.toString())));
     
      return req;
    }
View Full Code Here

    /**
     * 订阅群通知
     */
    public SipcRequest createSubscribeGroupNotifyRequest(String uri)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.SUBSCRIBE);
      req.addHeader(SipcHeader.EVENT, "PGPresence");
     
      req.setBody(new SipcBody(MessageTemplate.TMPL_SUBSCRIBE_GROUP_NOPTIFY.replace("{uri}", uri)));
     
      return req;
    }
View Full Code Here

    /**
     * 开始群会话
     */
    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;
    }
View Full Code Here

    /**
     * 确认会话收到请求
     */
    public SipcRequest createAckRequest(String uri)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.ACK);
      req.addHeader(SipcHeader.TO, uri);
     
      req.setNeedReplyTimes(0);
      return req;
     
    }
View Full Code Here

    /**
     * 群在线请求
     */
    public SipcRequest createGroupKeepLiveRequest(String uri)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.INFO);
      req.addHeader(SipcHeader.TO, uri);
     
      req.setBody(new SipcBody(MessageTemplate.TMPL_GROUP_KEEP_LIVE));
     
      return req;
    }
View Full Code Here

    /**
     * 群消息
     */
    public SipcRequest createSendGroupChatMessageRequest(String uri, String message)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.MESSAGE);
      req.addHeader(SipcHeader.CONTENT_TYPE, "text/html-fragment");
      req.addHeader(SipcHeader.CONTENT_TYPE, "text/plain");
      req.addHeader(SipcHeader.SUPPORTED, "SaveHistory");
      req.addHeader(SipcHeader.TO, uri);
      req.setBody(new SipcBody(message));
     
      return req;
    }
View Full Code Here

    /**
     * 设置群状态
     */
    public SipcRequest createSetGroupPresenceRequest(String uri, int presense)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.SERVICE);
      req.addHeader(SipcHeader.EVENT, "PGSetPresence");
      String body = MessageTemplate.TMPL_GROUP_SET_PRESENCE;
    body = body.replace("{uri}", uri);
    body = body.replace("{presence}", Integer.toString(presense));
     
      req.setBody(new SipcBody(body));
     
      return req;
    }
View Full Code Here

     * @param state
     * @return
     */
    public SipcRequest createSendChatStateRequest(String state)
    {
      SipcRequest req = this.createDefaultSipcRequest(SipcMethod.INFO);
     
      if(state.equals("nudge")){
        req.addHeader("RQ","nudge");
      }
     
      req.setBody(new SipcBody("<is-composing><state>"+state+"</state></is-composing>"));
     
      return req;
    }
View Full Code Here

TOP

Related Classes of net.solosky.maplefetion.sipc.SipcRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.