TransJam Collaboration ServerTransJam Client Programming Tutorial
|
A client can use a ClientAdapter which receives all of the messages that can be sent. If you would like to handle specific messages, then you can redefine the method that receives that method. This is similar to the WindowAdapter class in the AWT.
For example, here is a subclass of ClientAdapter that receives messages sent from other clients. The message contains the value of a Scrollbar in text format. The value is parsed and then printed.
ClientAdapter clientAdapter = new ClientAdapter() { // This message was sent to everyone in the room including the sender. // For this Applet, it contains the value of the senders Scrollbar in text format. public void sentAll( int uid, String text ) throws IOException { int value = Integer.parseInt( text ); System.out.println("User " + uid + " sent value = " + value ); } };Here we ask that our ClientAdapter be called when messages arrive from the server. By specifying Client.APPLICATION_LEVEL we can request that we only get messages when in a room specific to the application. We will not be sent messages that involve logging in or choosing a room.
client.addMessageListener( clientAdapter, Client.APPLICATION_LEVEL );
(C) 2002 SoftSynth.com