NearbyMessage constructor

NearbyMessage(
  1. Uint8List payload, {
  2. bool isAuthenticated = false,
})

Implementation

NearbyMessage(Uint8List payload, {this.isAuthenticated = false}) {
  var boundary = 0;

  var messageTypeByte = BytesUtils.getBytesRangeAsIntList(
      payload, boundary, boundary += const Int8().getBytesAmount());
  messageType =
      NearbyMessageType.fromInt8(BytesUtils.getInt8(messageTypeByte));

  var dateTimeBytes = BytesUtils.getBytesRangeAsIntList(
      payload, boundary, const Int64().getBytesAmount());
  dateTime =
      DateTime.fromMillisecondsSinceEpoch(BytesUtils.getInt64(dateTimeBytes));
  boundary += const Int64().getBytesAmount();

  var pSizeBytes = BytesUtils.getBytesRangeAsIntList(
      payload, boundary, const Int64().getBytesAmount());
  pSize = BytesUtils.getInt64(pSizeBytes);
  boundary += const Int64().getBytesAmount();

  var messageBytes =
      BytesUtils.getBytesRangeAsIntList(payload, boundary, pSize);
  message = Uint8List.fromList(messageBytes);
  boundary += pSize;

  var signatureBytes = BytesUtils.getBytesRangeAsIntList(
      payload, boundary, payload.length - boundary);
  signature = Uint8List.fromList(signatureBytes);
}