Confirmed users
177
edits
(Created page with "Some aspects of front and actor design can be tricky to understand, even for experienced engineers. The following are several best practices you should keep in mind when addi...") |
|||
Line 6: | Line 6: | ||
A better choice is for the actor to do all clean up itself when it's notified that the connection goes away. Then there's no need for the client to send any clean up message, and we know the actor will be in a good state no matter what. | A better choice is for the actor to do all clean up itself when it's notified that the connection goes away. Then there's no need for the client to send any clean up message, and we know the actor will be in a good state no matter what. | ||
You can do this by implementing your actor's <code>disconnect</code> method: | |||
<nowiki> | |||
disconnect: function() { | |||
return this.destroy(); | |||
},</nowiki> | |||
Also, ensure that the actor's <code>destroy</code> is really destroying everything that it should. | |||
With <code>protocol.js</code> actors, if your creates child actors for further functionality, in most cases you should call: | |||
<nowiki> | |||
this.manage(child);</nowiki> | |||
from the parent, so that the child is destroyed when the parent is. |