无法从ConcurrentHashMap - Java获得价值

时间:2016-08-09 08:37:36

标签: java smartfoxserver

我需要一些帮助,我无法理解为什么我无法获得我想要的价值。这里是我试图做的代码

RouletteExtension.java

public class RouletteExtension extends SFSExtension {
   private ConcurrentHashMap<Integer,PlayerHandler> players = null;
   @Override
   public void init() {
      players = new ConcurrentHashMap<Integer,PlayerHandler>();
   }
   public ConcurrentHashMap<Integer, PlayerHandler> getPlayers() {
      return players;
   }
   public void setPlayers(ConcurrentHashMap<Integer, PlayerHandler> players) {
      this.players = players;
   }
}

PlayerHandler.java

public class PlayerHandler {
   private int id = 0;
   User sfsUser = null;
   public PlayerHandler() {}
   public PlayerHandler(int id, User sfsUser) {
      this.id = id;
      this.sfsUser = sfsUser;
   }

   public int getId() {
      return id;
   }
   public void setId(int id) {
      this.id = id;
   }

   public User getSfsUser() {
      return sfsUser;
   }
   public void setSfsUser(User sfsUser) {
      this.sfsUser = sfsUser;
   }
}

BettingHandler.java

public class BettingHandler extends BaseClientRequestHandler {
   @Override
   public void handleClientRequest(User user, ISFSObject params) {
      RouletteExtension gameExt = (RouletteExtension) getParentExtension();
      PlayerHandler a = gameExt.getPlayers().get(user.getId());
      trace ("testOne = ", gameExt.getPlayers());
      trace ("testTwo = ",user.getId());
      trace ("testThree = ", a);
   }
}

这个SFS2X服务器端的脚本,我实际上是java新手,所以我想知道a是什么价值,当我在区域监视器中跟踪时只显示这个

{RouletteExt}: testOne =  {}
{RouletteExt}: testTwo =  1

testThree 没有出现,所以有问题,有人可以告诉我如何解决这个问题,并解释一下这里发生了什么,谢谢

0 个答案:

没有答案