incompl/cloak — pull request #78 by Markleford (2014-04-21 20:42:45+00:00)
Title: On user.delete() immediately make disconnected

The strongest use case for user.connected() is in the memberLeaves handler for a room. Here, we're going to want to know if the user changed rooms or was actually disconnected, and act accordingly (e.g. save state). This would typically be differentiated via a call to user.delete().

Thus, setting the property that yields our .connected() result within user.delete() needs to happen before the call to this.leaveRoom(). As implemented, I allowed a previous (older) disconnect stamp to remain, in case .delete() is called from another cleanup function.

This seemed to be the simpler solution to serving a practical use. An alternative that could still be considered would be to support an onDisconnect handler for users, but there's no reason why both can't exist.