Package cn.com.zjtelecom.smgp.bean

Examples of cn.com.zjtelecom.smgp.bean.Result


    submit.setMsgContent(content.getBytes("iso-10646-ucs-2"));
    submit.setMsgFormat(8);
    if (productid!=null) submit.setProductID(productid);
   
    //���Ͷ���
    Result  result =client.Send(submit);
    System.out.println("Status:"+result.ErrorCode);
    System.out.println("MsgID:"+result.ErrorDescription);
   
    //�˳�
    client.Close();
View Full Code Here


    this.clientEventInterface.OnSubmitResp(submitResp);
  }

  public synchronized Result Login() {

    Result result = new Result();
    try {
      LoginMessage lm = new LoginMessage(this.ClientID,
          this.ClientPasswd, this.LoginMode);
      SendBuf(lm.getBuf());
      // out.write(lm.getBuf());
View Full Code Here

  public synchronized int Send(Submit submit) throws SubmitException {

    if (submit.getMsgContent().length > 200) {

      throw new SubmitException((new Result(4, "Message too Long")));
    }

    Vector tlv = new Vector();
    if (this.SPID != null && !this.SPID.equals("")) {
      tlv.add(new Tlv(TlvId.MsgSrc, this.SPID));
    }
    if (submit.getProductID() != null && !submit.getProductID().equals("")) {
      tlv.add(new Tlv(TlvId.Mserviceid, submit.getProductID()));
    }

    if (submit.getLinkID() != null && !submit.getLinkID().equals("")) {
      tlv.add(new Tlv(TlvId.LinkID, submit.getLinkID()));
    }

    if (submit.getOtherTlvArray() != null) {
      for (int i = 0; i < submit.getOtherTlvArray().length; i++) {
        tlv.add(submit.getOtherTlvArray()[i]);
      }
    }
    Tlv[] tlvarray = new Tlv[tlv.size()];
    // System.out.println("tlvlen:"+tlv.size());
    for (int i = 0; i < tlv.size(); i++) {
      // System.out.println(((Tlv)tlv.get(i)).Value);
      tlvarray[i] = (Tlv) tlv.get(i);
    }

    String[] desttermidarray = new String[1];
    desttermidarray[0] = submit.getDestTermid();
    if (SequenceId++ == 0x7FFFFF) {
      SequenceId = 0;
    }

    int tmpseq = SequenceId;
    SubmitMessage sm = new SubmitMessage(submit.getMsgType(), submit
        .getNeedReport(), submit.getPriority(), submit.getServiceID(),
        submit.getFeetype(), submit.getFeeCode(), submit.getFixedFee(),
        submit.getMsgFormat(), submit.getValidTime(), submit
            .getAtTime(), submit.getSrcTermid(), submit
            .getChargeTermid(), desttermidarray, submit
            .getMsgLength(), submit.getMsgContent(), submit
            .getReserve(), tlvarray, tmpseq);
    try {
      // System.out.println(Hex.rhex(sm.getBuf()));
      SendBuf(sm.getBuf());
      // out.write(sm.getBuf());
      if (this.DisplayMode >= 2) {
        DisplayPackage(sm.getBuf(), 1);
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      throw new SubmitException(new Result(-1, "Socket Error!"));

    }

    tmpSubmitResp.put(tmpseq, new SubmitResp(submit));
View Full Code Here

        DisplayPackage(sm.getBuf(), 1);
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      return (new Result(-1, "Socket Error!"));

    }

    while (this.CurPack == null
        || this.CurPack.ReqestId != RequestId.Submit_Resp) {
      try {
        synchronized (this) {
          wait();
        }

      } catch (RuntimeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    Result result = new Result();
    SubmitRespMessage srm = new SubmitRespMessage(this.CurPack.Message);
    // if (srm==null) {
    // return (new Result(-1,"Login Fail"));
    // } else {
    return (new Result(srm.getStatus(), srm.getMsgID()));
    // }

  }
View Full Code Here

    }
  }

  public synchronized Result Login() {
       if (this.HasConnect == false) {
         return new Result(-2,"Can not creat socket!");
       }
    Result result = new Result();
    try {
      LoginMessage lm = new LoginMessage(this.ClientID,
          this.ClientPasswd, this.LoginMode);
      SendBuf(lm.getBuf());
      // out.write(lm.getBuf());
View Full Code Here

  public synchronized Result SendWapPush(String desc, String url,
      String srcTermId, String destTermid, String productID) {

    Submit[] submitarray = WapPushPdu.getWapPushSubmit(desc, url,
        srcTermId, destTermid, destTermid, productID);
    Result result = null;
    Result resulttmp = null;
    for (int i = 0; i < submitarray.length; i++) {
      resulttmp = this.Send(submitarray[i]);
      // System.out.println(Hex.rhex(submitarray[i].getMsgContent()));
      if (result == null || resulttmp.ErrorCode != 0) {
        result = resulttmp;
View Full Code Here

  public synchronized Result SendWapPush(String desc, String url,
      Submit submit) {

    Submit[] submitarray = WapPushPdu.getWapPushSubmit(desc, url, submit);
    Result result = null;
    Result resulttmp = null;
    for (int i = 0; i < submitarray.length; i++) {
      resulttmp = this.Send(submitarray[i]);
      // System.out.println(Hex.rhex(submitarray[i].getMsgContent()));
      if (result == null || resulttmp.ErrorCode != 0) {
        result = resulttmp;
View Full Code Here

     * if (submit.isLong()) { // ������ // submit.getMsgContent().length; }
     * else { }
     */

    if (submit.getMsgContent().length > 200) {
      return (new Result(4, "Message too Long"));
    }
    Vector<Tlv> tlv = new Vector<Tlv>();
    if (this.SPID != null && !this.SPID.equals("")) {
      tlv.add(new Tlv(TlvId.MsgSrc, this.SPID));
    }
    if (submit.getProductID() != null && !submit.getProductID().equals("")) {
      tlv.add(new Tlv(TlvId.Mserviceid, submit.getProductID()));
    }
   
    if (submit.getTP_udhi()==1){
      tlv.add(new Tlv(TlvId.TP_udhi,String.valueOf(1)));
    }

    if (submit.getLinkID() != null && !submit.getLinkID().equals("")) {
      tlv.add(new Tlv(TlvId.LinkID, submit.getLinkID()));
    }

    if (submit.getOtherTlvArray() != null) {
      for (int i = 0; i < submit.getOtherTlvArray().length; i++) {
        tlv.add(submit.getOtherTlvArray()[i]);
      }
    }
    Tlv[] tlvarray = new Tlv[tlv.size()];
    // System.out.println("tlvlen:"+tlv.size());
    for (int i = 0; i < tlv.size(); i++) {
      // System.out.println(((Tlv)tlv.get(i)).Value);
      tlvarray[i] = (Tlv) tlv.get(i);
    }

    String[] desttermidarray = new String[1];
    desttermidarray[0] = submit.getDestTermid();
    if (SequenceId++ == 0x7FFFFF) {
      SequenceId = 0;
    }

    int tmpseq = SequenceId;
    SubmitMessage sm = new SubmitMessage(submit.getMsgType(), submit
        .getNeedReport(), submit.getPriority(), submit.getServiceID(),
        submit.getFeetype(), submit.getFeeCode(), submit.getFixedFee(),
        submit.getMsgFormat(), submit.getValidTime(), submit
            .getAtTime(), submit.getSrcTermid(), submit
            .getChargeTermid(), desttermidarray, submit
            .getMsgLength(), submit.getMsgContent(), submit
            .getReserve(), tlvarray, tmpseq);
    try {
      // System.out.println(Hex.rhex(sm.getBuf()));
      SendBuf(sm.getBuf());
      // out.write(sm.getBuf());
      if (this.DisplayMode >= 2) {
        DisplayPackage(sm.getBuf(), 1);
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      return (new Result(-1, "Socket Error!"));

    }

    long sendTime = getTimeStamp();

    /*
     * while ((getTimeStamp() - sendTime) < 60000 && (this.CurPack == null
     * || this.CurPack.ReqestId != RequestId.Submit_Resp ||
     * this.CurPack.SequenceId != tmpseq)) {
     */
    Package tmppack = new Package();
    while ((getTimeStamp() - sendTime) < 60000
        && ((tmppack = checkPackage(tmpseq, RequestId.Submit_Resp)) == null)) {
      // checkPackage(int, int)
      try {
        synchronized (this) {
          wait(60000);
        }

      } catch (RuntimeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (tmppack != null) {
      SubmitRespMessage srm = new SubmitRespMessage(tmppack.Message);
      return (new Result(srm.getStatus(), srm.getMsgID()));
    } else {
      System.out.println("SubmitResp��ʱ��" + "Seq:" + tmpseq);
      return (new Result(-1, "00000000000000000000"));

    }

    // if (srm==null) {
    // return (new Result(-1,"Login Fail"));
View Full Code Here

        DisplayPackage(sm.getBuf(), 1);
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      return (new Result(-1, "Socket Error!"));

    }

    while (this.CurPack == null
        || this.CurPack.ReqestId != RequestId.Submit_Resp) {
      try {
        synchronized (this) {
          wait();
        }

      } catch (RuntimeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    Result result = new Result();
    SubmitRespMessage srm = new SubmitRespMessage(this.CurPack.Message);
    // if (srm==null) {
    // return (new Result(-1,"Login Fail"));
    // } else {
    return (new Result(srm.getStatus(), srm.getMsgID()));
    // }

  }
View Full Code Here

TOP

Related Classes of cn.com.zjtelecom.smgp.bean.Result

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.