ContentHeader.fromByteData constructor

ContentHeader.fromByteData(
  1. TypeDecoder decoder
)

Implementation

ContentHeader.fromByteData(TypeDecoder decoder) {
  classId = decoder.readUInt16();
  decoder.skipBytes(2); // Skip weight
  bodySize = decoder.readUInt64();

  int propertyMask = decoder.readUInt16();
  if (propertyMask == 0) {
    return;
  }

  properties = MessageProperties();

  // Read properties depending on the property presence mask.
  // Property presense bits are stored from high -> low starting at bit 15
  if (propertyMask & 0x8000 != 0) {
    properties!.contentType = decoder.readShortString();
  }
  if (propertyMask & 0x4000 != 0) {
    properties!.contentEncoding = decoder.readShortString();
  }
  if (propertyMask & 0x2000 != 0) {
    properties!.headers = decoder.readFieldTable("headers");
  }
  if (propertyMask & 0x1000 != 0) {
    properties!.deliveryMode = decoder.readUInt8();
  }
  if (propertyMask & 0x800 != 0) {
    properties!.priority = decoder.readUInt8();
  }
  if (propertyMask & 0x400 != 0) {
    properties!.corellationId = decoder.readShortString();
  }
  if (propertyMask & 0x200 != 0) {
    properties!.replyTo = decoder.readShortString();
  }
  if (propertyMask & 0x100 != 0) {
    properties!.expiration = decoder.readShortString();
  }
  if (propertyMask & 0x80 != 0) {
    properties!.messageId = decoder.readShortString();
  }
  if (propertyMask & 0x40 != 0) {
    properties!.timestamp = decoder.readTimestamp();
  }
  if (propertyMask & 0x20 != 0) {
    properties!.type = decoder.readShortString();
  }
  if (propertyMask & 0x10 != 0) {
    properties!.userId = decoder.readShortString();
  }
  if (propertyMask & 0x8 != 0) {
    properties!.appId = decoder.readShortString();
  }
  if (propertyMask & 0x4 != 0) {
    decoder.readShortString();
  }
}