use of com.mapia.domain.Room in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class MessageHandler method broadcasting.
@MessageMapping("/vote/{roomId}")
@SendTo("/from/vote/{roomId}")
public GameResult broadcasting(VoteMessage voteMessage, @DestinationVariable long roomId) throws Exception {
log.debug("voteMessage arrived: /vote/{}, voteMessage: {}", roomId, voteMessage);
Room gameRoom = lobby.getRoom(roomId);
return gameRoom.returnVoteResult(voteMessage);
}
use of com.mapia.domain.Room in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class ApiRoomController method exitUserFromRoom.
private long exitUserFromRoom(User user) {
long currentRoomId = user.getEnteredRoomId();
Room room = lobby.getRoom(currentRoomId);
room.exit(user);
if (room.isEmpty()) {
lobby.delRoom(currentRoomId);
}
return currentRoomId;
}
use of com.mapia.domain.Room in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class ApiRoomController method enter.
@GetMapping("/{id}")
public RoomResult enter(@PathVariable long id, HttpSession session, Model model) {
if (!HttpSessionUtils.isLoginUser(session)) {
return RoomResult.invalidAccess(id);
}
User user = HttpSessionUtils.getUserFromSession(session);
if (!lobby.isExistRoom(id)) {
session.removeAttribute(HttpSessionUtils.USER_SESSION_KEY);
if (!user.isLobby()) {
exitUserFromRoom(user);
}
return RoomResult.invalidAccess(id);
}
Room room = lobby.getRoom(id);
if (!user.isAbleToEnter(id)) {
session.removeAttribute(HttpSessionUtils.USER_SESSION_KEY);
exitUserFromRoom(user);
return RoomResult.invalidAccess(id);
}
if (room.isFull()) {
return RoomResult.rejectToEnterRoomOfFull(id);
}
if (room.isSecretMode()) {
//TODO Add secret mode logic
}
room.enter(user);
model.addAttribute("room", room);
model.addAttribute("user", user);
return RoomResult.successToEnterRoom(id);
}
Aggregations