FileDocCategorySizeDatePackage
ChessServer.javaAPI DocExample1167Sat Jan 31 23:24:58 GMT 1998dcj.examples.messageV1

ChessServer

public class ChessServer extends BasicMsgHandler
Source code from "Java Distributed Computing", by Jim Farley. Class: ChessServer Example: 6-5 Description: An agent that wraps around a local ChessPlayer and handles the network communication with the remote opponent.

Fields Summary
ChessPlayer
player
Constructors Summary
public ChessServer(InputStream in, OutputStream out)

    super(in, out);
    player = new ChessPlayer();
  
Methods Summary
protected BasicMessagebuildMessage(java.lang.String msgId)

    BasicMessage msg = null;

    System.out.println("Got message type \"" + msgId + "\"");

    if (msgId.compareTo("move") == 0) {
      msg = new MoveMessage(player);
    }
    else if (msgId.compareTo("confirm") == 0) {
      msg = new ConfirmMoveMessage(player);
    }
    else if (msgId.compareTo("reject") == 0) {
      msg = new RejectMoveMessage(player);
    }
    else if (msgId.compareTo("concede") == 0) {
      msg = new ConcedeMessage(player);
    }

    return msg;
  
public ChessPlayergetPlayer()

    return player;