CmdrZin
31may09
Launching server and client.
java -jar bin/sgs-boot.jar tutorial/conf/7400_Darkstar.boot
Plan 6
Exercise 5. Adding Chat
First things first. Read the entire text of Exercise 5 and note key
points and concepts.
Channel based messaging
Server controlled create and join
Note: The code changes are also in
\solutions\exercise5\com\sun\sgs\darkmud\core\
Do Step 1b. Add code changes to MudUser.java : CommandType enumeration.
Add YELL. Don't forget the comma on LOGOUT.
Do Step 1c-e: Add code changes to parseInnerCommand( )
Do Step 1f: Add code to commitCommand( )
opps..code problems with
byte[] bytes = command.getAnnouncement().getBytes();
AppContext.getChannelManager().getChannel(CHAT).send(bytes);
fix it with do to API changes
ByteBuffer bc = ByteBuffer.wrap(command.getAnnouncement().getBytes());
ClientSession session = getSession();
AppContext.getChannelManager().getChannel(CHAT).send(session,bc);
Do Step 2b: static initializer?? not familiar with this type of code
structure.
Add code under declarations per solution code...two no-symbol errors...use
Fix-Imports from hint.
Do Step 2c: Add setClientSessio( ) code
give it all a try..launch server and two clients from NetBeans..woo
yoo..can yell to each other..whoopy.
oops..one little bug..sendToUser trys to get a session befor testing
if the seesion exists..
Fix by moving getSession() call to inside if test....
Change
ClientSession session = getSession();
if ((sessionRef != null) && session.isConnected())
{
ByteBuffer bb = ByteBuffer.wrap(text.getBytes());
session.send(bb);
}
to
if (sessionRef != null) {
ClientSession session
= getSession();
if (session.isConnected())
{
ByteBuffer bb = ByteBuffer.wrap(text.getBytes());
session.send(bb);
}
}
working now..
I declare Plan 6 a success..source code changes in fixedUp7400srcL5.zip
and in SVN for project.