lizhanwei
2020-02-17 b3b6a944ac3f8279a04f496bc2c4533a92555a71
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package safeluck.drive.evaluation.platformMessage;
 
import android.util.Log;
 
import com.anyun.im_lib.util.ByteUtil;
 
public class AuthMessage extends DriveExamProtocol {
 
    private static final String TAG = "AuthMessage";
    private static final int BODY_LENGTH = 12;
    private long timeStamp;
    private String hexStrPwd;
 
    public String getHexStrPwd() {
        return hexStrPwd;
    }
 
    public void setHexStrPwd(String hexStrPwd) {
        this.hexStrPwd = hexStrPwd;
    }
 
    /**
     * 构造函数
     *
     * @param msg_id 消息ID
     */
    public AuthMessage(short msg_id) {
        super(msg_id);
    }
 
    @Override
    protected byte[] createMessageBody() {
        byte[] messageBody = new byte[BODY_LENGTH];
        int pos = 0;
        timeStamp = System.currentTimeMillis();
        Log.i(TAG, "createMessageBody: timeStamp="+timeStamp);
        byte[] timeStampBytes = ByteUtil.intGetBytes((int)timeStamp);
        System.arraycopy(timeStampBytes,0,messageBody,pos,timeStampBytes.length);
        pos+= 4;
        byte [] hexPwdBytes = ByteUtil.hexStr2Bytes(hexStrPwd);
        System.arraycopy(hexPwdBytes,0,messageBody,pos,hexPwdBytes.length);
        return messageBody;
    }
 
    @Override
    protected short msgBodyLength() {
        return BODY_LENGTH;
    }
}