Added RootDObjectManager.newInterval() for creating intervals that are
automatically canceled when the omgr is shutdown (they actually cancel themselves if they fire after the omgr has been shutdown, which stock intervals also do, but these guys do so quietly because we know they mean to work that way). Made use of that new method and the fluent schedule methods in various places. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5880 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -31,8 +31,6 @@ import com.google.inject.Inject;
|
||||
|
||||
import com.samskivert.util.ArrayIntSet;
|
||||
import com.samskivert.util.IntSet;
|
||||
import com.samskivert.util.Interval;
|
||||
import com.samskivert.util.Lifecycle;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
|
||||
@@ -59,7 +57,7 @@ import static com.threerings.crowd.Log.log;
|
||||
* Handles chat channel services.
|
||||
*/
|
||||
public abstract class ChatChannelManager
|
||||
implements ChannelSpeakProvider, Lifecycle.ShutdownComponent
|
||||
implements ChannelSpeakProvider
|
||||
{
|
||||
/**
|
||||
* When a body becomes a member of a channel, this method should be called so that any server
|
||||
@@ -111,30 +109,19 @@ public abstract class ChatChannelManager
|
||||
});
|
||||
}
|
||||
|
||||
// from interface Lifecycle.Shutdowner
|
||||
public void shutdown ()
|
||||
{
|
||||
// stop our channel closer; always be closing... except now
|
||||
_closer.cancel();
|
||||
_closer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates our singleton manager and registers our invocation service.
|
||||
*/
|
||||
@Inject protected ChatChannelManager (PresentsDObjectMgr omgr, InvocationManager invmgr,
|
||||
Lifecycle cycle)
|
||||
@Inject protected ChatChannelManager (PresentsDObjectMgr omgr, InvocationManager invmgr)
|
||||
{
|
||||
invmgr.registerDispatcher(new ChannelSpeakDispatcher(this), CrowdCodes.CROWD_GROUP);
|
||||
cycle.addComponent(this);
|
||||
|
||||
// create and start our idle channel closer (always be closing)
|
||||
_closer = new Interval(omgr) {
|
||||
@Override public void expired () {
|
||||
// create and start our idle channel closer; this will run as long as omgr is alive
|
||||
omgr.newInterval(new Runnable() {
|
||||
public void run () {
|
||||
closeIdleChannels();
|
||||
}
|
||||
};
|
||||
_closer.schedule(IDLE_CHANNEL_CHECK_PERIOD, true);
|
||||
}).schedule(IDLE_CHANNEL_CHECK_PERIOD, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,9 +378,6 @@ public abstract class ChatChannelManager
|
||||
public long lastMessage;
|
||||
}
|
||||
|
||||
/** Used to close channels that have not had any activity in a few minutes. */
|
||||
protected Interval _closer;
|
||||
|
||||
/** Contains pending messages for all channels currently being resolved. */
|
||||
protected Map<ChatChannel,List<UserMessage>> _resolving = Maps.newHashMap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user