diff --git a/lib/src/Core/ExceptionCode.dart b/lib/src/Core/ExceptionCode.dart index 4312b52..5a9d2dd 100644 --- a/lib/src/Core/ExceptionCode.dart +++ b/lib/src/Core/ExceptionCode.dart @@ -30,5 +30,6 @@ enum ExceptionCode PropertyNotFound, SetPropertyDenied, ReadOnlyProperty, - GeneralFailure + GeneralFailure, + AddToStoreFailed } \ No newline at end of file diff --git a/lib/src/Net/IIP/DistributedConnection.dart b/lib/src/Net/IIP/DistributedConnection.dart index 560a8dc..2ca14ae 100644 --- a/lib/src/Net/IIP/DistributedConnection.dart +++ b/lib/src/Net/IIP/DistributedConnection.dart @@ -1521,11 +1521,14 @@ class DistributedConnection extends NetworkConnection with IStore // create the resource var resource = null; //Activator.CreateInstance(type, args) as IResource; - Warehouse.put(resource, name, store as IStore, parent); - - sendReply(IIPPacketAction.CreateResource, callback) + Warehouse.put(resource, name, store as IStore, parent).then((ok) { + sendReply(IIPPacketAction.CreateResource, callback) .addUint32(resource.instance.id) .done(); + }).error((ex){ + // send some error + sendError(ErrorType.Management, callback, ExceptionCode.AddToStoreFailed.index); + }); }); }); @@ -2303,19 +2306,32 @@ class DistributedConnection extends NetworkConnection with IStore { //print("New template "); - // ClassId, ResourceAge, ResourceLink, Content - if (resource == null) - Warehouse.put(dr, id.toString(), this, null, tmp); - var d = rt[3] as DC; - Codec.parsePropertyValueArray(d, 0, d.length, this).then((ar) + // ClassId, ResourceAge, ResourceLink, Content + if (resource == null) { - //print("attached"); - dr.attach(ar); - _resourceRequests.remove(id); - reply.trigger(dr); - }); + Warehouse.put(dr, id.toString(), this, null, tmp).then((ok){ + Codec.parsePropertyValueArray(d, 0, d.length, this).then((ar) + { + //print("attached"); + dr.attach(ar); + _resourceRequests.remove(id); + reply.trigger(dr); + }); + }).error((ex) => reply.triggerError(ex)); + } + else + { + Codec.parsePropertyValueArray(d, 0, d.length, this).then((ar) + { + //print("attached"); + dr.attach(ar); + _resourceRequests.remove(id); + reply.trigger(dr); + }); + } + }).error((ex) { reply.triggerError(ex); diff --git a/lib/src/Resource/Warehouse.dart b/lib/src/Resource/Warehouse.dart index 22e5df1..7c271f3 100644 --- a/lib/src/Resource/Warehouse.dart +++ b/lib/src/Resource/Warehouse.dart @@ -384,6 +384,8 @@ class Warehouse { }).error((ex) => rt.triggerError(ex)); } + // return new name + return rt; }