mirror of
https://github.com/esiur/esiur-js.git
synced 2025-06-27 15:23:11 +00:00
April
This commit is contained in:
@ -37,15 +37,24 @@ export default class DistributedResource extends IResource
|
||||
destroy()
|
||||
{
|
||||
this.destroyed = true;
|
||||
this._p.attached = false;
|
||||
this._p.connection.sendDetachRequest(this._p.instanceId);
|
||||
this._emit("destroy", this);
|
||||
}
|
||||
|
||||
_suspend()
|
||||
{
|
||||
this._p.suspended = true;
|
||||
this._p.attached = false;
|
||||
}
|
||||
|
||||
constructor(connection, instanceId, age, link)
|
||||
{
|
||||
super();
|
||||
|
||||
this._p = {
|
||||
isAttached: false,
|
||||
suspended: false,
|
||||
attached: false,
|
||||
connection: connection,
|
||||
instanceId: instanceId,
|
||||
age: age,
|
||||
@ -66,13 +75,16 @@ export default class DistributedResource extends IResource
|
||||
return props;
|
||||
}
|
||||
|
||||
_attached(properties)
|
||||
_attach(properties)
|
||||
{
|
||||
|
||||
if (this._isAttached)
|
||||
if (this._p.attached)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
|
||||
this._p.suspended = false;
|
||||
|
||||
for(var i = 0; i < properties.length; i++)
|
||||
{
|
||||
this.instance.setAge(i, properties[i].age);
|
||||
@ -81,7 +93,7 @@ export default class DistributedResource extends IResource
|
||||
}
|
||||
|
||||
|
||||
this._p.isAttached = true;
|
||||
this._p.attached = true;
|
||||
|
||||
var self = this;
|
||||
|
||||
@ -154,6 +166,9 @@ export default class DistributedResource extends IResource
|
||||
if (this.destroyed)
|
||||
throw new Error("Trying to access destroyed object");
|
||||
|
||||
if (this._p.suspended)
|
||||
throw new Error("Trying to access suspended object");
|
||||
|
||||
if (index >= this.instance.template.functions.length)
|
||||
throw new Error("Function index is incorrect");
|
||||
|
||||
@ -164,6 +179,9 @@ export default class DistributedResource extends IResource
|
||||
if (this.destroyed)
|
||||
throw new Error("Trying to access destroyed object");
|
||||
|
||||
if (this._p.suspended)
|
||||
throw new Error("Trying to access suspended object");
|
||||
|
||||
if (index >= this.instance.template.functions.length)
|
||||
throw new Error("Function index is incorrect");
|
||||
|
||||
|
Reference in New Issue
Block a user