Package net.shadewind.racetrack

Examples of net.shadewind.racetrack.CommException


        String line = in.readLine();
        if (line == null)
          break;
        Command command = Command.parseCommand(line);
        if (command == null)
          throw new CommException("Malformed command: " + line);
        processCommand(command);
      }
    } catch (Exception e) {
      logger.log(Level.WARNING, "Exception in client handler", e);
    } finally {
View Full Code Here


    if (name == null) {
      logger.log(Level.INFO, command.toString());
      if (command.getName().equals("hello"))
        processHello(command);
      else
        throw new CommException("Unexpected command, expected hello.");
    } else {
      switch (command.getName()) {
      case "start":
        processStart(command);
        break;
       
      case "drive":
        processDrive(command);
        break;
       
      default:
        throw new CommException("Unknown command \"" + command.getName() + "\".");
      }
    }
  }
View Full Code Here

      while (!socket.isClosed()) {
        String line = in.readLine();
        logger.info(line);
        Command command = Command.parseCommand(line);
        if (command == null)
          throw new CommException("Malformed command.");
        processCommand(command);
      }
    } catch (Exception e) {
      // TODO notify about error
      logger.log(Level.SEVERE, "Communication error.", e);
View Full Code Here

      case "welcome":
        processWelcome(command);
        break;
       
      default:
        throw new CommException("Unexpected command, expected welcome or busy.");
      }
    } else {
      switch (command.getName()) {
      case "player":
        processPlayer(command);
        break;
       
      case "availableMap":
        processAvailableMap(command);
        break;
       
      case "lobby":
        processLobby(command);
        break;
       
      case "gameStarted":
        processGameStarted(command);
        break;
     
      case "carReset":
        processCarReset(command);
        break;
       
      case "playerTurn":
        processPlayerTurn(command);
        break;
       
      case "carDriven":
        processCarDriven(command);
        break;
       
      case "carCrashed":
        processCarCrashed(command);
        break;
       
      case "carFinished":
        processCarFinished(command);
        break;
       
      case "endGame":
        processEndGame(command);
        break;
       
      case "playerLeft":
        processPlayerLeft(command);
        break;
       
      case "busy":
        processBusy(command);
        break;
     
      default:
        throw new CommException("Unexpected command: " + command.getName());
      }
    }
  }
View Full Code Here

  private void processCarReset(Command command) throws CommException
  {
    int playerId = command.intArgument(0);
    Player player = players.get(playerId);
    if (player == null)
      throw new CommException("Unknown player id = " + playerId);
    Car car = player.getCar();
    car.reset();
    car.pushPosition(new Vector2i(
        command.intArgument(1),
        command.intArgument(2)));
View Full Code Here

 
  private void processCarDriven(Command command) throws CommException
  {
    Player player = players.get(command.intArgument(0));
    if (player == null)
      throw new CommException("Player is unknown.");
   
    Car car = player.getCar();
    car.pushPosition(new Vector2i(command.intArgument(1), command.intArgument(2)));
    car.setVelocity(new Vector2i(command.intArgument(3), command.intArgument(4)));
    listener.carDriven(player);
View Full Code Here

 
  private void processCarCrashed(Command command) throws CommException
  {
    Player player = players.get(command.intArgument(0));
    if (player == null)
      throw new CommException("Player is unknown.");
   
    Car car = player.getCar();
    car.setCrashed(true);
    listener.carCrashed(player);
  }
View Full Code Here

 
  private void processCarFinished(Command command) throws CommException
  {
    Player player = players.get(command.intArgument(0));
    if (player == null)
      throw new CommException("Player is unknown.");
   
    Car car = player.getCar();
    car.setFinished(true);
    listener.carFinished(player);
  }
View Full Code Here

 
  private void processPlayerLeft(Command command) throws CommException
  {
    Player player = players.get(command.intArgument(0));
    if (player == null)
      throw new CommException("Player is unknown.");
   
    synchronized (players) {
      players.remove(player.getId());
      listener.playerLeft(player);
    }
View Full Code Here

TOP

Related Classes of net.shadewind.racetrack.CommException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.