setAttributes method

AsyncReply<bool> setAttributes(
  1. IResource resource,
  2. Structure attributes, [
  3. bool clearAttributes = false
])

Implementation

AsyncReply<bool> setAttributes(IResource resource, Structure attributes,
    [bool clearAttributes = false]) {
  var rt = new AsyncReply<bool>();

  sendRequest(clearAttributes
      ? IIPPacketAction.UpdateAllAttributes
      : IIPPacketAction.UpdateAttributes)
    ..addUint32(resource.instance?.id as int)
    ..addDC(Codec.composeStructure(attributes, this, true, true, true))
    ..done()
        .then<dynamic>((ar) => rt.trigger(true))
        .error((ex) => rt.triggerError(ex));

  return rt;
}