示例#1
0
  @RequestMapping("/join")
  public WebServiceResponse joinGame(
      @RequestParam(required = true, name = "session") String boardSessionId) {
    WebServiceResponse response = new WebServiceResponse();

    thisLogger.log(
        Level.INFO,
        "New join request, ref: {0} with board session id: {1} .",
        new Object[] {boardSessionId});

    try {
      String[] gameRefs = gameService.registerAndJoinGame(boardSessionId);
      response.getResponseObject().setMessage(newJoinMsg);
      response.getResponseObject().setBoardSession(gameRefs[0]);
      response.getResponseObject().setPlayerRef(gameRefs[1]);
      response.getResponseObject().setChipColor(gameRefs[2]);
      response.getResponseMetaData().success();
    } catch (InvalidGameSessionException | MaxPlayerRegisteredException ex) {
      response.getResponseMetaData().failure(HttpStatus.BAD_REQUEST.value(), ex.getMessage());
    }

    return response;
  }