create method
Create a new resource.
The store in which the resource is saved.
Class full name.
Constructor parameters.
Resource attributeds.
Values for the resource properties.
Implementation
AsyncReply<DistributedResource?> create(
IStore store,
IResource parent,
String className,
List parameters,
Structure attributes,
Structure values) {
var reply = new AsyncReply<DistributedResource?>();
var pkt = BinaryList()
..addUint32((store.instance as Instance).id)
..addUint32((parent.instance as Instance).id)
..addUint8(className.length)
..addString(className)
..addDC(Codec.composeVarArray(parameters, this, true))
..addDC(Codec.composeStructure(attributes, this, true, true, true))
..addDC(Codec.composeStructure(values, this));
pkt.insertInt32(8, pkt.length);
(sendRequest(IIPPacketAction.CreateResource)..addDC(pkt.toDC())).done()
..then((args) {
if (args != null) {
var rid = args[0];
fetch(rid).then((r) {
reply.trigger(r);
});
} else {
reply.triggerError(Exception("Null response"));
}
});
return reply;
}