sendLoginMsg method

Future sendLoginMsg()

Implementation

Future sendLoginMsg() async {
  SystemInfo systemInfo = SystemInfo();
  await systemInfo.init();
  String deviceName = systemInfo.deviceName;
  // DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
  String channelName = 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": channelName,
    "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 + 1);
  protobuf[0] = 3;
  protobuf.setRange(1, data.length + 1, data);
  channel!.send(protobuf);
}