//
// $Id: BasicDirector.java,v 1.2 2002/09/20 00:54:39 mdb Exp $

package com.threerings.presents.client;

import com.threerings.presents.util.PresentsContext;

/**
 * Handles functionality common to nearly all client directors. They
 * generally need to be session observers so that they can set themselves
 * up when the client logs on (by overriding {@link #clientDidLogon}) and
 * clean up after themselves when the client logs off (by overriding
 * {@link #clientDidLogoff}).
 */
public class BasicDirector
    implements SessionObserver
{
    /**
     * Derived directors will need to provide the basic director with a
     * context that it can use to register itself with the necessary
     * entities.
     */
    protected BasicDirector (PresentsContext ctx)
    {
        // listen for session start and end
        Client client = ctx.getClient();
        client.addClientObserver(this);

        // if we're already logged on, fire off a call to fetch services
        if (client.isLoggedOn()) {
            fetchServices(client);
        }
    }

    // documentation inherited from interface
    public void clientDidLogon (Client client)
    {
        fetchServices(client);
    }

    // documentation inherited from interface
    public void clientObjectDidChange (Client client)
    {
    }

    // documentation inherited from interface
    public void clientDidLogoff (Client client)
    {
    }

    /**
     * Derived directors can override this method and obtain any services
     * they'll need during their operation via calls to {@link
     * Client#getService}. It will automatically be called when the client
     * logs on or when the director is constructed if it is constructed
     * after the client is already logged on.
     */
    protected void fetchServices (Client client)
    {
    }
}

@@ -31,29 +31,29 @@
 v 1.
-2
+3
  200
-2/09/20 00:54:39
+3/12/11 21:36:12
  mdb
@@ -1034,24 +1034,65 @@
 es(client);%0A
+            clientObjectUpdated(client);%0A
         %7D%0A  
@@ -1089,16 +1089,16 @@
       %7D%0A
-
     %7D%0A%0A 
@@ -1222,24 +1222,61 @@
 es(client);%0A
+        clientObjectUpdated(client);%0A
     %7D%0A%0A    /
@@ -1368,32 +1368,69 @@
 t client)%0A    %7B%0A
+        clientObjectUpdated(client);%0A
     %7D%0A%0A    // do
@@ -1458,32 +1458,32 @@
  from interface%0A
-
     public void 
@@ -1523,24 +1523,303 @@
    %7B%0A    %7D%0A%0A
+    /**%0A     * Called in three circumstances: when a director is created and we've%0A     * already logged on; when we first log on and when the client object%0A     * changes after we've already logged on.%0A     */%0A    protected void clientObjectUpdated (Client client)%0A    %7B%0A    %7D%0A%0A
     /**%0A    

Add a single method that we call in the various circumstances where our client object has been updated so that the 90% of the directors that just need to know any time that sort of thing happens so that they can listen on the current client object can easily and robustly do so.