Terminate actors when they have no more facets left.

This commit is contained in:
Tony Garnock-Jones 2016-03-18 17:08:49 -04:00
parent dea733911d
commit 3c124633b3
1 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,13 @@ Actor.prototype.addFacet = function(facet) {
this.facets = this.facets.add(facet);
};
Actor.prototype.removeFacet = function(facet) {
this.facets = this.facets.remove(facet);
if (this.facets.isEmpty()) {
Network.exit();
}
};
//---------------------------------------------------------------------------
function createFacet() {
@ -130,6 +137,7 @@ Facet.prototype.terminate = function() {
});
Network.stateChange(aggregate);
this.endpoints = Immutable.Map();
this.actor.removeFacet(this);
};
//---------------------------------------------------------------------------