本文整理匯總了Java中net.dlogic.kryonet.common.constant.ErrorMessage.ROOM_DOESNT_EXIST屬性的典型用法代碼示例。如果您正苦於以下問題:Java ErrorMessage.ROOM_DOESNT_EXIST屬性的具體用法?Java ErrorMessage.ROOM_DOESNT_EXIST怎麽用?Java ErrorMessage.ROOM_DOESNT_EXIST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類net.dlogic.kryonet.common.constant.ErrorMessage
的用法示例。
在下文中一共展示了ErrorMessage.ROOM_DOESNT_EXIST屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addUserToRoom
public void addUserToRoom(User user, String roomName) throws RoomManagerException {
if (!map.containsKey(roomName)) {
throw new RoomManagerException(ErrorMessage.ROOM_DOESNT_EXIST);
}
Room room = map.get(roomName);
if (room.isFull()) {
throw new RoomManagerException(ErrorMessage.ROOM_IS_FULL);
}
if (room.users.containsKey(user.id)) {
throw new RoomManagerException(ErrorMessage.USER_ALREADY_IN_ROOM);
}
room.users.put(user.id, user);
}
示例2: removeUserFromRoom
public void removeUserFromRoom(User user, String roomName) throws RoomManagerException {
if (!map.containsKey(roomName)) {
throw new RoomManagerException(ErrorMessage.ROOM_DOESNT_EXIST);
}
Room room = map.get(roomName);
if (!room.users.containsKey(user.id)) {
throw new RoomManagerException(ErrorMessage.USER_NOT_IN_ROOM);
}
room.users.remove(user.id);
}