public void handleRequest( ReplyServer replyServer, ByteChannel channel, byte[] requestBytes ) throws IOException {
String request = new String( requestBytes );
StringTokenizer st = new StringTokenizer( request );
String command = st.nextToken();
switch (command.toLowerCase()) {
case "load":
Card card = Track.loadCard(st.nextToken());
downloadCard( replyServer, channel, card );
break;
case "download":
DownloadCommand downloadCommand = new DownloadCommand(st);
downloadCard( replyServer, channel, downloadCommand.getTrack().getCurrentCard());
break;
case "bet":
BetCommand betCommand = new BetCommand(st);
betCommand.getPool().addBet(betCommand.getHorseNum(), betCommand.getAmount());
if (betCommand.forCurrentWinPool() && betCommand.getTrack().hasEnoughBets()
&& _stopWatch.getElapsedTimeInSeconds() >= ODDS_UPDATE_INTERVAL) {
displayCurrentOdds(betCommand);
}
break;
case "display":
DisplayCommand displayCommand = new DisplayCommand(st);
displayCommand.getTrack().setCurrentRace(displayCommand.getRaceNum());
_stopWatch.resetElapsedTime();
displayLineOdds(displayCommand);
break;
case "results":
ResultsCommand resultsCommand = new ResultsCommand(st);
displayResults(resultsCommand);
}
}