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

📄 message.java~1~

📁 采用JAVA开发
💻 JAVA~1~
字号:
package com.gctech.sms.sp.cms.msg;
import java.io.*;
import com.gctech.sms.sp.cms.util.*;
public class Message implements java.io.Serializable{
  int totalLength = 0;
  int commandId = 0;
  int commandStatus = 0;
  int sequenceId = 0;


  public Message()
  {
  }


  public static void main(String[] args) {
    Message message1 = new Message();
  }


  public static Message create(InputStream in)
  {
    // 读取消息长度
    byte[] totalLengthByte = new byte[4];
    try
    {
      int realSize = in.read(totalLengthByte);
      if(realSize!=4)
      {
        return new ErrorMessage("无法读到Message长度,realSize应该为4,但为"+realSize,totalLengthByte);
      }
    }
    catch(Exception e)
    {
      return new ErrorMessage("无法读到Message长度:"+e.getMessage());
    }
    int totalLength = TypesTools.byte2int(totalLengthByte);
    //读取消息内容
    byte[] bs = new byte[totalLength];

    try
    {
      int  realSize = in.read(bs);
      if(realSize != bs.length) {
        return new ErrorMessage("无法读到Message长度,realSize应该为"+totalLength+",但为"+realSize);
      }

    }
    catch(Exception ex)
    {
      return new ErrorMessage(ex.getMessage());
    }



    int commandId = TypesTools.byte2int(bs,0);
    switch (commandId)
    {
      case LOGIN_RES:
      {
        Message m = LoginResMessage.createMessage(bs);
        return m ;
      }
      case 2:;
    }


    return null;
  }

  public static final int ERROR_MSG = 0x00000000;
  //登录
  public static final int LOGIN_REQ = 0x00000001;
  public static final int LOGIN_RES = 0x80000001;
//提交
  public static final int SUBMIT_REQ = 0x00000002;
  public static final int SUBMIT_RES = 0x80000002;
//订阅
  public static final int SUBSCRIBE_REQ = 0x00000003;
  public static final int SUBSCRIBE_RES = 0x80000003;
//退订
  public static final int UNSUBSCRIBE_REQ = 0x00000004;
  public static final int UNSUBSCRIBE_RES = 0x80000004;
//测试
  public static final int ACTIVE_TEST_REQ = 0x00000005;
  public static final int ACTIVE_TEST_RES = 0x80000005;
//退出
  public static final int EXIT_REQ = 0x00000006;
  public static final int EXIT_RES = 0x80000006;
//Deliver短信上行
  public static final int DELIVER = 0x00000010;
  public static final int DELIVER_RESP = 0x80000010;


}

⌨️ 快捷键说明

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