Ejemplo n.º 1
0
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/html");

    String username = req.getUserPrincipal().getName();

    String token = ChannelServiceFactory.getChannelService().createChannel(username);
    String tokenized =
        CharStreams.toString(
                new InputStreamReader(getServletContext().getResourceAsStream(PATH), ENCODING))
            .replace("TOKEN", token);

    DatastoreService store = DatastoreServiceFactory.getDatastoreService();
    Entity player = ensurePlayerExists(username, store);
    Entity map = ensureMapExists(player, store);

    OutputStream out = resp.getOutputStream();
    out.write(ENCODING.encode(tokenized).array());
    out.flush();
  }