I just wanted to clarify. If I create ChannelListeners that are ManagedObjects and don't keep a reference around it never goes away?
Yup. This is in the tutorial.
The API takes a managed reference to it. As soon as a managed reference to it is taken, the Object Store ebcoems aware of it and starts saving state.
The only way to get access to those listeners after they are created unless I keep a reference to them myself some how is via named binding. When the user leaves the channel it is essentially garbage. As there is no way to get a reference to it again unless I kept one originally or it is name bound. How would I go about destroying it?
Put a name on it or keep a reference. As you said.
How would I know when to destroy it?
If the client drops, then you get a disconnected() callback and you can delete all listeners associated with that client.
That is the only way for a client to leave a channel other then under the control of your logic where again you can clean up.
In general though I would recommend one of two strategies though. Either:
(A) Have a Managed Object as an event listener that you use over and over
(B) Dont use a managed object for the listener and it will go away when not needed.
But the code that calls leave() has no way to access the Listener and the listener has no way to know the user left or the channel's been closed as the API stands today..
I don't follow you. if you need to track this, create a ManagedObject that maintains a Map and call it when you need that info. or just keep a list of the channels you are joined to on your user object.