incompl/cloak — pull request #71 by jugglinmike (2014-03-23 03:57:17+00:00)
Title: Completely destroy instance state in `cloak.stop`

Cloak does not offer any recovery transition from the "stopped" state.
After invoking `cloak.stop`, clients must call `clock.run` before
continuing to interact with the library. In that case, the original
socket will be discarded and a new one created in its place.

Because of this, all state associated with the disconnected socket
should be removed in response to any `stop` operation.

Event handlers specified in calls to `cloack.configure` must be
partially applied--only newly-specified handlers should be re-bound (and
only if `clock.run` has been invoked). Care has been taken to preserve
existing behavior of Cloak:

- The `messages` option, when specified, completely removes any
previously-bound `message` event handlers before binding the new
handlers it describes.
- The `serverEvents` option, when specified, is merged into the
collection of server event handlers.