22may09 CmdrZin

To run the server
    Copy 7400_Darkstar.jar

    then open a Command Propt window and cd to the install area
    and use
       java -jar bin/sgs-boot.jar tutorial/conf/7400_Darkstar.boot
    to launch the server. This is based on all of the setups and conf files made so far.
To start the client,  run the 7400_Darkstar project from NetBeans. The Main is set to the Mud client.

Plan 3

Proceeding to Exercise 2 of Lab 7400
First thing, verify my environment since it's been a few days.
Start up NetBeans and get the latest updates. Clean and problems.
Copy jar file to launch area, open a Command window, and launch server then lanuch client.
Logs in, echos back..every thing working. Close client and then stop server with a Ctrl-C.

Ok, Excercise 2. Launch Foxfire and Open File
and click on Exercise 2 tab to read what to do.
Opps..forgot to finish Exercise 1..need to fix up to respond with
"you can't do anything" message.
Use the code from to prepare the ByteBuffer message for use.
  byte[] msg = new byte[message.capacity()];
  /* Looks strange, but it does copy the message into the array. */
Build, copy jar over, and test. Cool, now it responds with a "You can't do that" message.
This was Exercise 1:Step 5:Item 7.
Note: Use Step 6:Without the NetBean IDE to clear the server database if needed.
Step 7 can now be done over and over ... Exercise 1 IS now done. Read the Summary.

Exercise 2: Read through the entire exercise first.
Hmm..may have to tweak the code to get this to work since it uses all those byte[] for messages.
Also need to make new .boot and .properties files for running MudMain.
Peeking ahead..seems the MudMain server uses MudUser class ( see loggedIn()) as the ClientSessionListener
to implement the receivedMessage() interface..but first, going to make the new files for running.
In the
folder, modify file by changing
and save. The # is for comments and if you want to run the basic server again, just have to uncomment the SimpleServer line and comment out the MudMain line.
Build and test, but I dont think this will fly yet. Still using
        java -jar bin/sgs-boot.jar tutorial/conf/7400_Darkstar.boot
to launch server, but now it will try to lauch MudMain instead of SimpleServer.
Hmm..still runs the SimpleServer..guess I need to deleted the db to clear the server.
DOH..need to delete the dsdb in
   ...\sgs-server-dist-0.9.9\tutorial\data\7400_Darkstar\dsdb ran the MudMain server..and up popped the ManagedObject not referenced error.
This is the session error..have to recode to use a ref and then use the .get() to retrieve the session.
Changing (reference code changes needed for
Also, change the parameter session to ses, then make a new session and have the rest of the code us it.
        Using code from SimpleServer:SimpleListener()

  if (ses == null) {
   throw new NullPointerException("null session");
  sessionRef = AppContext.getDataManager().createReference(ses);
  sessionName = ses.getName();

to set up a ref for the session. Also add globals as private, but not final.
     ClientSession session = sessionRef.get();
Build and test to see how happy this made it...not very...seems com.sun.sgs.darkmud.core.MudUser is complaining.
Try commenting out code in MudMain:lookupUser() so it returns null all the time...clear, build, run
still error on ClientSession in MudUser...hmm..added SimpleServer:getSession() method in utility area to use it when a ClientSession is needed.
            ClientSession session = getSession();        Replaces previous change.
Use sessionName in lookupUser() call since it already exists.
            MudUser user = lookupUser(sessionName);
hmm..also chang the MudUser constructor call..this may be the problem spot.
            user = new MudUser(sessionName);
bah..putting a System.out.println() after lookupUser call to output sessionName. the print out before the to be in a MudUser method.
Move println to after new MudUser() call..print out before error..
Move to after AppContext. call..still comes out before error..
Move to after .setClientSession() call..nope
Move to after bcast.send() call..nope
Move after .joinChannel() call..nope
after sendToUser??..bah
Use "entered the game" message for output...hmm..prints game not in this area???
Moved to MudUser:sendToUser()..bah
comment out MudMain: :user.sendToUser() call..bah
Ok..comment out all code after lookupUser()..which returns sys error,
but Status set: Log in failed on client...
Uncomment the if-else block..hmm..logged error..try entering error
in receivedMessage..ReadOnlyBufferException...had this use   byte[] msg = new byte[message.capacity()];
  /* Looks strange, but it does copy the message into the array. */
  String command = new String(msg).trim();

code in MudUser:receivedMessage()..woo hoo..fixed that get a MudObject:301 ref error when text is entered..go back to commented out code to see if this was its problem.
Uncomment if user != null block...same old error
Comment code after user.setLoggedIn()..error
Comment out .setClientSession()...ah hah..Logged errors.
NOTE: This ManagedObject / ManagedReference concept is confusing.
Going to recode MudUser to be sent a
instead of a ClientSession and then have it "get" the session when needed, also copy getSession() method from MudMain.
Changed setClientSession() and everywhere that session is used add
    ClientSession session = getSession();
Change disconnected() to null out sessionRef
Uncomment out setClientSession() and pass sessionRef instead of session.
Logged errors..uncomment out the rest of the if block...woo hoo..Logged in and
get the Welcome to the DarkMUD message!!!
Uncomment the lookupUser code...should be able to relogin now and be remembered..yes
Get the Welcome back after closing client then reruning client an use the same name.
Ok, now to fix the Object ref errors..
Changes to
  // Added stuff
  Iterator iter = inventory.iterator();
  while (iter.hasNext()) {
   ManagedReference<MudObject> ref = (ManagedReference<MudObject>);
    MudObject obj = ref.get();

    if (showInvisible || obj.isVisible()) {
new code to pull stuff out of an inventory.
Summary..can now login, logout, look, and it remembers user.
One last Clean and Build..

I declare Plan 3 successful
eek. 01:35am..