⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmppquery.java

📁 短信系统SMS:支持普通短信、长短信和wap push短信的发送。
💻 JAVA
字号:
package com.ekun.sms.cmpp2;

import java.io.*;

public class CmppQuery
{

  public CmppQuery(CmppSocket sock)
  {
    /*初始化*/
    curTime = "";
    QueryType = 0;
    QueryCode = "";
    Reserve = "Reserve";

    this.sock = sock;
    SequenceId = 0;
    CommandID = 6;

    /*设置CMPP_Connect包长*/
    TotalLength = 39;

    /*分配CMPP_Query包体*/
    bodybytes = new byte[27];

    /*设置包头*/
    headbytes = new byte[12];
    CmppCommon.BytesCopy(CmppCommon.IntToBytes4(TotalLength), headbytes, 0, 3,
                         0);
    CmppCommon.BytesCopy(CmppCommon.IntToBytes4(CommandID), headbytes, 0, 3, 4);
    CmppCommon.BytesCopy(CmppCommon.IntToBytes4(SequenceId), headbytes, 0, 3, 8);
  }

  /*名称:setcmppQuerys
   * 功能:设置CMPP_Connect包项目
   * 输入参数:SourceAddr,AuthenticatorSP,Version,timestamp
   *
   * 输出参数:无
   *
   * 返回值:无
   */
  public void setcmppQuerys(String curTime, int QueryType, String QueryCode,
                            String Reserve)
  {
    int cur_pos = 0;

    byte bcurTime[] = new byte[8];
    bcurTime = curTime.getBytes();
    CmppCommon.BytesCopy(bcurTime, bodybytes, 0, bcurTime.length - 1, cur_pos);
    cur_pos += 8;

    bodybytes[cur_pos] = (byte) QueryType;
    cur_pos++;

    byte bQueryCode[] = new byte[10];
    bQueryCode = QueryCode.getBytes();
    CmppCommon.BytesCopy(bQueryCode, bodybytes, 0, bQueryCode.length - 1,
                         cur_pos);
    cur_pos += 10;

    byte bReserve[] = new byte[8];
    bReserve = Reserve.getBytes();
    CmppCommon.BytesCopy(bReserve, bodybytes, 0, bReserve.length - 1, cur_pos);
  }

  /*名称:sendcmppQuery
   * 功能:发送CMPP_Connect包
   * 输入参数:无
   *
   * 输出参数:无
   *
   * 返回值:>0:包序列号,-1:失败
   */
  public int sendcmppQuery()
  {
    int i = 0;
    try
    {
      sock.bout.write(headbytes);
      sock.bout.write(bodybytes);
      sock.bout.flush();
    }
    catch (IOException e)
    {
      System.out.println(e.toString());
      i = -5;
      return i;
    }
    catch (NullPointerException npe)
    {
      i = -5;
      return -5;
    }

    return i;
  }

  /*名称:getTotalLength
   * 功能:返回包总长度
   * 输入参数:
   *
   * 输出参数:无
   *
   * 返回值:包总长度
   */
  public int getTotalLength()
  {
    return TotalLength;
  }

  /*名称:setSequenceId
   * 功能:设置SequenceId项目
   * 输入参数:SequenceId
   *
   * 输出参数:无
   *
   * 返回值:无
   */
  public void setSequenceId(int SequenceId)
  {
    this.SequenceId = SequenceId;
    CmppCommon.BytesCopy(CmppCommon.IntToBytes4(SequenceId), headbytes, 0, 3, 8);
  }

  public byte bodybytes[]; /*包体*/
  public byte headbytes[]; /*包头*/

  String curTime;
  int QueryType;
  String QueryCode;
  String Reserve;

  private int CommandID; //包类型
  private int SequenceId; //包序列号
  int TotalLength;
  CmppSocket sock; //socket链路
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -