sendLoginMsg method
Implementation
Future sendLoginMsg() async {
SystemInfo systemInfo = SystemInfo();
await systemInfo.init();
String deviceName = systemInfo.deviceName;
// DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
String channel = systemInfo.deviceName;
String systemVersion = systemInfo.version;
String deviceId = hex.encode(
md5.convert(const Utf8Encoder().convert(systemInfo.deviceId)).bytes);
Map<String, String> map = {
"uid": uid!, //主id
"channel": channel,
"appVersion": sOCKETAPPVERSION,
"osVersion": systemVersion,
"packageName": "cn.asihe.cim",
"deviceId": deviceId,
// (await PlatformDeviceId.getDeviceId)!.replaceAll("-", ""), //应用id
"deviceName": '$deviceName ${systemInfo.model}',
"language": "zh-CN",
};
int time = DateTime.now().millisecondsSinceEpoch;
Int64 timeStamp = Int64.parseInt(time.toString());
var body = sentbody.Model(data: map);
body.key = "client_bind";
body.timestamp = timeStamp;
var data = body.writeToBuffer();
var protobuf = Uint8List(data.length + 3);
protobuf[0] = 3;
protobuf[1] = (data.length & 0xff);
protobuf[2] = ((data.length >> 8) & 0xff);
protobuf.setRange(3, data.length + 3, data);
socket!.add(protobuf);
await socket!.flush();
onConnectionStatusChanged(true);
if (timer.isActive()) {
timer.cancel();
}
}