this.connectedUsers = connectedUsers;
}
@Override
public Map<ReturnableData, Object> handle(final RequestWrapper request, final HttpSession session) {
final User user = (User) session.getAttribute(SessionAttribute.USER);
assert (user != null);
final String params = request.getParameter(AjaxRequest.MESSAGE);
final String[] args = (params == null || params.isEmpty()) ? new String[0] : params.trim()
.split(" ");
final User target = (args.length > 0) ? connectedUsers.getUser(args[0]) : user;
if (null == target) {
return error(ErrorCode.NO_SUCH_USER);
}
final Game game = target.getGame();
if (null == game) {
return error(ErrorCode.INVALID_GAME);
}
final Player player = game.getPlayerForUser(target);
if (null == player) {