import 'dart:convert'; import '../io_tool/io_tool.dart'; import 'io_reply.dart'; import 'io_sender.dart'; import 'io_type.dart'; class GetPrivateKeyCommand extends SenderProtocol { String? lockID; String? keyID; // 钥匙ID String? authUserID; // 钥匙授权人ID int? nowTime; String? authCode; int? needAuthor; GetPrivateKeyCommand({ this.lockID, this.keyID, this.authUserID, this.nowTime, this.authCode, }) : super(CommandType.getLockPrivateKey); @override List messageDetail() { List data = []; print("lockID:${lockID!} lockID.utf8.encode${utf8.encode(lockID!)}"); // 锁id int lockIDLength = utf8.encode(lockID!).length; data.addAll(utf8.encode(lockID!)); data = getFixedLengthList(data, 40 - lockIDLength); //KeyID 40 int keyIDLength = utf8.encode(keyID!).length; data.addAll(utf8.encode(keyID!)); data = getFixedLengthList(data, 40 - keyIDLength); //authUserID 40 int authUserIDLength = utf8.encode(authUserID!).length; data.addAll(utf8.encode(authUserID!)); data = getFixedLengthList(data, 20 - authUserIDLength); //NowTime 4 DateTime now = DateTime.now(); int timestamp = now.millisecondsSinceEpoch; data.add((timestamp & 0xff000000) >> 24); data.add((timestamp & 0xff0000) >> 16); data.add((timestamp & 0xff00) >> 8); data.add((timestamp & 0xff)); if(needAuthor == 0){ data.add(0); }else{ } return data; } } class GetPrivateKeyReply extends Reply { GetPrivateKeyReply.parseData(CommandType commandType, List dataDetail) : super.parseData(commandType, dataDetail) { print('获取私钥'); int index = 0; // while(index < endIndex){ // commandKey = byteUInt8(dataDetail, index); // index += offset_1; // switch(commandKey){ // // } // } } }