sendLoginMsg method

Future sendLoginMsg()

Implementation

Future sendLoginMsg() async {
  SystemInfo systemInfo = SystemInfo();
  await systemInfo.init();
  String deviceName = devicename ?? systemInfo.deviceName;
  // DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
  String channelN = channelName ?? systemInfo.deviceName;
  String systemVersion = osVersion ?? systemInfo.version;
  String deviceId = deviceid ??
      hex.encode(md5
          .convert(const Utf8Encoder().convert(systemInfo.deviceId))
          .bytes);

  Map<String, String> map = {
    "uid": uid!, //主id
    "channel": channelN,
    "appVersion": sOCKETAPPVERSION,
    "osVersion": systemVersion,
    "packageName": packageName ?? "cn.asihe.cim",
    "deviceId": deviceId,
    // (await PlatformDeviceId.getDeviceId)!.replaceAll("-", ""), //应用id
    "deviceName": '$deviceName',
    "language": 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);
}