endian11
2019-12-18 516bfa1d3919e2236aba5c07348b2bd1234ed94f
修改消息基类    @Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
super.channelActive(ctx);
Log.i(TAG, "channelActive: ");

} 会导致异常,
2个文件已修改
30 ■■■■ 已修改文件
app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
im_lib/src/main/java/com/anyun/im_lib/LoginAuthRespHandler.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/bean/DriveExamProtocol.java
@@ -23,7 +23,7 @@
    //标识位
    private byte MESSAGE_TAIL = 0x7e;
//校验码  先暂时写死
    private int checkCode = 0x78;
    private byte checkCode = 0x78;
/***===========以下是消息头=============***/
@@ -35,8 +35,8 @@
    //消息体属性
    private int msg_property;
    //终端手机号
    private String phoneOnTerminal;
    //终端手机号 字符串长度必须为16
    private String phoneOnTerminal = "0008618513021245";
//13    消息流水号    WORD    按发送顺序从0开始循环累加
    public static short msg_serial_num=0;
@@ -65,29 +65,31 @@
        //标识位
        desBytes[pos] = MESSAGE_HEAD;
        pos++;
        //协议版本号
        byte[] protoVersion = ByteUtil.shortGetByte(protocol_version);
        System.arraycopy(protoVersion,0,desBytes,pos,protoVersion.length);
        pos +=protoVersion.length;
//消息ID
    //消息ID
        byte[] msgIdBytes = ByteUtil.shortGetBytes(msg_id);
        System.arraycopy(msgIdBytes,0,desBytes,pos,msgIdBytes.length);
        pos+=msgIdBytes.length;
//消息体属性
    //消息体属性
        byte[] msg_pro_bytes = ByteUtil.shortGetBytes((short)2);
        System.arraycopy(msg_pro_bytes,0,desBytes,pos,msg_pro_bytes.length);
        pos+=msg_pro_bytes.length;
        //终端手机号
        byte[] phoneBytes = ByteUtil.str2Bcd("1234567890121518");
        byte[] phoneBytes = ByteUtil.str2Bcd(phoneOnTerminal);
        System.arraycopy(phoneBytes,0,desBytes,pos,phoneBytes.length);
        pos+=phoneBytes.length;
//消息流水号
    //消息流水号
        byte[] msg_serialNum = ByteUtil.shortGetBytes(msg_serial_num++);
        System.arraycopy(msg_serialNum,0,desBytes,pos,msg_serialNum.length);
        pos+=msg_serialNum.length;
//保留
        //保留
        desBytes[pos] = 0;
        pos++;
@@ -97,13 +99,15 @@
        pos+=messageBodyBytes.length;
        //校验码
        desBytes[pos] = 0x01;
        // TODO: 2019/12/18 校验码需要计算   还有转义需要处理
        desBytes[pos] = checkCode;
        pos++;
        //末尾结束标识位
        desBytes[pos] = MESSAGE_TAIL;
        Log.i(TAG, "包长度="+(pos+1));
        Log.i(TAG, "包内容: "+ByteUtil.byte2HexStr(desBytes));
        return desBytes;
    }
im_lib/src/main/java/com/anyun/im_lib/LoginAuthRespHandler.java
@@ -4,6 +4,7 @@
import com.anyun.im_lib.interf.IMSClientInteface;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -19,6 +20,13 @@
    private static final String TAG = LoginAuthRespHandler.class.getSimpleName();
    private IMSClientInteface imsClient;
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        super.channelActive(ctx);
        Log.i(TAG, "channelActive: ");
    }
    /**
     * 构造函数
     * @param imsClient