From 811ccd0bf120419c766291ae08f835f1a323f6d1 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Sun, 27 Oct 2002 22:34:11 +0000 Subject: [PATCH] when the client logs off, forcibly clear all chat displays git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1850 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../crowd/chat/client/ChatDirector.java | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java index 066c18ae5..e09aa0714 100644 --- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java +++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java @@ -1,5 +1,5 @@ // -// $Id: ChatDirector.java,v 1.33 2002/08/14 19:07:49 mdb Exp $ +// $Id: ChatDirector.java,v 1.34 2002/10/27 22:34:11 ray Exp $ package com.threerings.crowd.chat; @@ -59,6 +59,9 @@ public class ChatDirector extends BasicDirector _ctx.getClient().getInvocationDirector().registerReceiver( new ChatDecoder(this)); + // watch the session, clear displays when the user logs off. + _ctx.getClient().addClientObserver(this); + // register ourselves as a location observer _ctx.getLocationDirector().addLocationObserver(this); } @@ -155,8 +158,18 @@ public class ChatDirector extends BasicDirector */ public void clearDisplays () { - for (Iterator iter = _displays.iterator(); iter.hasNext(); ) { - ((ChatDisplay) iter.next()).clear(); + clearDisplays(false); + } + + /** + * Request that all chat displays clear their contents. + * + * @param force if false, a display may choose to ignore the clear. + */ + protected void clearDisplays (boolean force) + { + for (int ii=0, nn=_displays.size(); ii < nn; ii++) { + ((ChatDisplay) _displays.get(ii)).clear(force); } } @@ -501,6 +514,22 @@ public class ChatDirector extends BasicDirector return _requestId++; } + // documentation inherited + public void clientObjectDidChange (Client client) + { + super.clientObjectDidChange(client); + + clearDisplays(true); + } + + // documentation inherited + public void clientDidLogoff (Client client) + { + super.clientDidLogoff(client); + + clearDisplays(true); + } + /** Our active chat context. */ protected CrowdContext _ctx;