getParents method

AsyncReply<List<IResource?>> getParents(
  1. IResource resource
)

Implementation

AsyncReply<List<IResource?>> getParents(IResource resource) {
  var rt = new AsyncReply<List<IResource?>>();

  sendRequest(IIPPacketAction.ResourceParents)
    ..addUint32((resource.instance as Instance).id)
    ..done().then<dynamic>((ar) {
      if (ar != null) {
        var d = ar[0] as DC;
        Codec.parseResourceArray(d, 0, d.length, this)
            .then<dynamic>((resources) {
          rt.trigger(resources);
        }).error((ex) => rt.triggerError(ex));
      } else {
        rt.triggerError(Exception("Null response"));
      }
    });

  return rt;
}