decoupling_client.html
18mar11 ndp
 24apr11

Decoupling the Client

Time to bite the bullet and finally decouple the Client from the Server code and make a Common shared library for data structures and definitions. It will only make the future changes easier...oh well.

First off, rename without refactoring (not delete) the com.sun.sgs.darkmud folder from the project and see what breaks. Any dependencies will go into a new Common project.
hmm..built ok so delete from project..now things break..delete .core files broken..looks
like MudObject is the first canidate.
Make a new Project->Java Class Library called ZMUcommon and put it in the ZMUohmyGame checkout directory with the Client and Server checkouts.
Add a com.sun.sgs.darkmud.core directory structure by adding succive folders to the Source Packages and put a copy of MudObject.java in the /core folder.
Add the sgs-server-api-0.10.1.jar to the Libraries using Add Jar/Folder and copy option.
Wait..backup..the only think needed from MudObject is the MudObject.MudType..
So let's just make that a class and put it in the Common project. All it has in it is the enum that was in MudObject.
public class MudType {
    public static enum Type {
        OBJECT, ITEM, ROOM, CHARACTER, USER, PLAYER
    }
}
Now we have to take the old enum out of MudObject and use the new..
First build the Common project to generate a library, then add that library to the ZMUohMyClient project Libraries.
ZMUcommon.jar will be in the dist folder and use relative path to it.
MudObject.MudType objects are now MudType.Type objects. So replace the type class where used..
public MudObject.MudType getObjectType() {
becomes
public MudType.Type getObjectType() {
Remember to add
import com.sun.sgs.darkmud.core.MudType;
to get the new class. Woo hoo, that fixedup PositionMessage.java. Only about 4 or 5 places needed replacements. Looks like Avatar.java need about the same fixings..ok..nothing broken in the Client anymore..next up..delete .map folder..ok..
delete CommandCanceledException.java (refactor safe check)
Now to remove the Map support since the Client has a 3D view now.
Delete
    MapDisplay.java, MapFrame.java, MapParchment.java, and Maproom.java
and UsersList.java also..nothing else broke..Direction.java can be deleted now..
also
    MudInitializationException.java, MudObjectInstantiationException.java, and Uncontained.java
The directory com.sun.sgs.darkmud.img and its files can also be deleted.
Now we move what left over from the core and messages into the Common project and adjust the Client to use them from there. This can be don by draging the files or folder from one project to the other and let the Refactor operation fix up the import entries.
..also needed to put back the server-api library in the Common Libraries folder..
Ok, the trees look like this now..
New Client Trees
 Should try it out first and then go fixup the Server to use the Common project for those files placed there.
Woo hoo..the Client  work with the Server in remote still. Need to commit the changes and restructure SVN a bit so the three projects all get checked out at once under a common directory.
Moved the ZMUohMyClient in under ZMUohMyNB with the others. Now you can get all three by checking out ZMUohMyNB.
I also copied the required Jar archives in to the ZMUcommon\lib directory and will have the Client and Server reference here rather that to the distribution folders.

24apr11
Time to stop being lazy and clean up the Server side code by removing the Client code from it. I was going to look into the Zombie Follow::doSomething bug that was gererating a NULL exception some times, but I figured I clean up the Server code first and migrate to the RD 10.2
distribution as well.

Changes to ZMUohMyNB project
    Delete the three 3d packages
    Delete the two darkmud.client packages
    Remove sgs-client.jar library
    Remove portfolio.jar library (used to load 3D models)
clean and build Server (ZMUohMyNB project)...no problem..think I'll need everything else..
Update the Libraries using the Add Jar/Folder option, use realtive paths..
    sgs-server-0.10.2.jar
    sgs-server-api-0.10.2.jar
    sgs-server-0.10.2-sources.jar
clean and build..run locally to verify all is good..(set Client to "localhost" to run locally)..
Go to the local 0.10.2 distribution directory..delete the tutorial/data directory (if there) to remove the old database, copy the dist/ZMUohMyNB.jar file into the tutorial directory to replace the old one..
Set up a command line window and CD to the distribution tutorial directory..
run
    java -jar bin/sgs-boot.jar tutorial/conf/ZMUohMyNB.boot
to launch the server from installation area. (easy to cut-n-paste)..should get an "application is ready" msg..
Run Client from NetBeans to check..ok..all good still..use
    java -jar bin/sgs-stop.jar
to stop the server. May have to use ctrl-C also...put Client back to IP address so all three project can be commited together..Clean and commit to svn..rev 238
Ok..all clean now..on to Follow fix..see ZombieFollowBug.html