Package scotlandyard.server.services

Source Code of scotlandyard.server.services.GameServiceImpl

package scotlandyard.server.services;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import scotlandyard.client.network.rpc.GameService;
import scotlandyard.server.GameServer;
import scotlandyard.shared.BoardState;
import scotlandyard.shared.Player;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class GameServiceImpl extends RemoteServiceServlet implements GameService {

  @Override
  public BoardState getBoardState() {
    HttpServletRequest request = this.getThreadLocalRequest();
    HttpSession session = request.getSession();
    GameServer game = (GameServer)session.getAttribute("GameServerInstance");
   
    return game.getBoardState();
  }

  @Override
  public void move(int destination) {
    HttpServletRequest request = this.getThreadLocalRequest();
    HttpSession session = request.getSession();
    GameServer game = (GameServer)session.getAttribute("GameServerInstance");
    Player player = (Player)session.getAttribute("PlayerInstance");
    System.out.println(player.getName()+" esta tentando se mover para "+destination);
    game.move(player, destination);
  }

  @Override
  public void interfaceReady() {
    HttpServletRequest request = this.getThreadLocalRequest();
    HttpSession session = request.getSession();
    GameServer game = (GameServer)session.getAttribute("GameServerInstance");
    Player player = (Player)session.getAttribute("PlayerInstance");
   
    game.checkAllInterfaceLoaded(player);
  }

  @Override
  public String getMyGameName() {
    HttpServletRequest request = this.getThreadLocalRequest();
    HttpSession session = request.getSession();
    GameServer game = (GameServer)session.getAttribute("GameServerInstance");
   
    return game.getGameName();
  }
}
TOP

Related Classes of scotlandyard.server.services.GameServiceImpl

TOP
Copyright © 2018 www.massapi.com. 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.