CmdrZin ([email protected])
22may09
rev:
To run the server
Copy 7400_Darkstar.jar from
...\7400_darkstar\darkstar\dist
to
...\sgs-server-dist-0.9.9\sgs-server-dist-0.9.9\tutorial
then open a Command Propt window and cd to the install
area
...\sgs-server-dist-0.9.9\sgs-server-dist-0.9.9
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 Build..no 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
C:\DATA\GameDevelopment\DarkStarGameEngine\7400_darkstar\darkstar\index.html
and click on Exercise 2 tab to read what to do.
Opps..forgot to finish Exercise 1..need to fix up SimpleServer.java:receiveMessage()
to respond with
"you can't do anything" message.
Use the code from MudClient.java:receiveMessage() to prepare the ByteBuffer
message for use.
-
byte[] msg = new byte[message.capacity()];
-
/* Looks strange, but it does
copy the message into the array. */
-
message.get(msg);
-
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 MudMain.java 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
...\sgs-server-dist-0.9.9\tutorial\conf
folder, modify 7400_Darkstar.properties file by changing
com.sun.sgs.app.listener=com.sun.sgs.darkmud.SimpleServer
to
# com.sun.sgs.app.listener=com.sun.sgs.darkmud.SimpleServer
com.sun.sgs.app.listener=com.sun.sgs.darkmud.MudMain
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
Yep..now 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 MudMain.java (reference code changes needed for SimpleServer.java)
Also, change the parameter session to ses, then make a new session
and have the rest of the code us it.
loggedIn()
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.
ok..got the print out before the error...hmm...got 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 message..so
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 null...HAH..no
sys error,
but Status set: Log in failed on client...
Uncomment the if-else block..hmm..logged in..no error..try entering
text..MudUser.java:165 error
in receivedMessage..ReadOnlyBufferException...had this before..so use
-
byte[] msg = new byte[message.capacity()];
-
/* Looks strange, but it does
copy the message into the array. */
-
message.get(msg);
-
String command = new String(msg).trim();
code in MudUser:receivedMessage()..woo hoo..fixed that part..now 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 in..no errors.
NOTE: This ManagedObject / ManagedReference concept is confusing.
Going to recode MudUser to be sent a
ManagedReference<ClientSession>
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 in..no 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 MudObject.java
getInventory()
// Added stuff
Iterator iter = inventory.iterator();
while (iter.hasNext()) {
ManagedReference<MudObject> ref = (ManagedReference<MudObject>)iter.next();
MudObject obj = ref.get();
if (showInvisible || obj.isVisible()) {
inv.add(obj);
}
}
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
zipping up source code into fixedUp7400srcL2.zip
eek. 01:35am..