Awesome response, particularly as I personally only call stop on self ;-) Thanks. Is this documented anywhere?

> On 1 Apr 2014, at 5:59 pm, Roland Kuhn <notifications@github.com> wrote:
> 
> In documentation/manual/javaGuide/main/async/JavaWebSockets.md:
> 
> > +The actor that we're sending to here in this case looks like this:
> > +
> > +@[actor](code/javaguide/async/MyWebSocketActor.java)
> > +
> > +Any messages received from the client will be sent to the actor, and any messages sent to the actor supplied by Play will be sent to the client.  The actor above simply sends every message received from the client back with `I received your message: ` prepended to it.
> > +
> > +### Detecting when a WebSocket has closed
> > +
> > +When the WebSocket has closed, Play will automatically stop the actor.  This means you can handle this situation by implementing the actors `postStop` method, to clean up any resources the WebSocket might have consumed.  For example:
> > +
> > +@[actor-post-stop](code/javaguide/async/JavaWebSockets.java)
> > +
> > +### Closing a WebSocket
> > +
> > +Play will automatically close the WebSocket when your actor that handles the WebSocket terminates.  So, to close the WebSocket, send a `PoisonPill` to your own actor:
> > +
> I don’t have the full context for this use-case, so let me just enumerate the options:
> 
> context.stop(notAChildActor) is a bad idea and should not ever be done, since if you are not in charge of the actor’s lifecycle you should not mess with it.
> context.stop(self) is perfectly fine.
> context.stop(someChildActor) is equivalent to pulling the plug: stop it (and its descendants) ASAP, either because of emergency termination or we know that they are not useful anymore to anyone.
> notAChildActor ! PoisonPill is a bad idea for the same reason as context.stop(notAChildActor).
> childActor ! PoisonPill may be fine if you know exactly what the child actor is doing; in particular this implies knowledge that the current mailbox contents are exactly what needs processing (since no further messages including replies will make it to that actor).
> self ! PoisonPill could potentially be useful if you find a compelling case.
> anyActor ! AnyActor.RequestShutdown is the only sensible way to shut down an actor whose life-cycle you don’t control. It is also the only way to perform an orderly shutdown of a whole actor hierarchy (since all other methods preclude communication after the stop signal, which is usually too restrictive).
> We will—in some distant future version—remove PoisonPill, and we will also remove the ability to context.stop() actors besides self and children.
> 
> —
> Reply to this email directly or view it on GitHub.