本文整理汇总了Java中net.dlogic.kryonet.common.constant.ErrorMessage类的典型用法代码示例。如果您正苦于以下问题:Java ErrorMessage类的具体用法?Java ErrorMessage怎么用?Java ErrorMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorMessage类属于net.dlogic.kryonet.common.constant包,在下文中一共展示了ErrorMessage类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAddUserToRoom_ThrowsRoomManagerException_RoomIsFull
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
@Test
public void testAddUserToRoom_ThrowsRoomManagerException_RoomIsFull() throws RoomManagerException {
exception.expect(RoomManagerException.class);
exception.expectMessage(ErrorMessage.ROOM_IS_FULL);
User user = new User();
user.id = 1;
user.username = "mike";
manager.addUserToRoom(user, "Test");
User user2 = new User();
user2.id = 2;
user2.username = "angelo";
manager.addUserToRoom(user2, "Test");
User user3 = new User();
user3.id = 3;
user3.username = "mack";
manager.addUserToRoom(user3, "Test");
}
示例2: addUserToRoom
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
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);
}
示例3: removeUserFromRoom
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
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);
}
示例4: testAddUserToRoom_ThrowsRoomManagerException_RoomDoesntExist
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
@Test
public void testAddUserToRoom_ThrowsRoomManagerException_RoomDoesntExist() throws RoomManagerException {
exception.expect(RoomManagerException.class);
exception.expectMessage(ErrorMessage.ROOM_DOESNT_EXIST);
User user = new User();
user.id = 1;
user.username = "mike";
manager.addUserToRoom(user, "Ghost");
assertTrue(manager.map.get("Test").users.containsKey(user.id));
}
示例5: testAddUserToRoom_ThrowsRoomManagerException_UserAlreadyInRoom
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
@Test
public void testAddUserToRoom_ThrowsRoomManagerException_UserAlreadyInRoom() throws RoomManagerException {
exception.expect(RoomManagerException.class);
exception.expectMessage(ErrorMessage.USER_ALREADY_IN_ROOM);
User user = new User();
user.id = 1;
user.username = "mike";
manager.addUserToRoom(user, "Test");
manager.addUserToRoom(user, "Test");
}
示例6: testRemoveUserFromRoom_ThrowsRoomManagerException_RoomDoesntExist
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
@Test
public void testRemoveUserFromRoom_ThrowsRoomManagerException_RoomDoesntExist() throws RoomManagerException {
exception.expect(RoomManagerException.class);
exception.expectMessage(ErrorMessage.ROOM_DOESNT_EXIST);
User user = new User();
user.id = 1;
user.username = "mike";
manager.removeUserFromRoom(user, "Ghost");
}
示例7: testRemoveUserFromRoom_ThrowsRoomManagerException_UserNotInRoom
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
@Test
public void testRemoveUserFromRoom_ThrowsRoomManagerException_UserNotInRoom() throws RoomManagerException {
exception.expect(RoomManagerException.class);
exception.expectMessage(ErrorMessage.USER_NOT_IN_ROOM);
User user = new User();
user.id = 1;
user.username = "mike";
manager.removeUserFromRoom(user, "Test2");
}
示例8: initialize
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
public static void initialize(int writeBufferSize, int objectBufferSize) throws IOException, KryonetClientException {
Log.debug("KryonetClientInstance.initialize(" + writeBufferSize + ", " + objectBufferSize + ")");
if (client != null) {
throw new KryonetClientException(ErrorMessage.CLIENT_ALREADY_INITIALIZED);
}
client = new KryonetClient(writeBufferSize, objectBufferSize);
}
示例9: getInstance
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
public static KryonetClient getInstance() throws KryonetClientException {
Log.debug("KryonetClientInstance.getInstance()");
if (client == null) {
throw new KryonetClientException(ErrorMessage.CLIENT_NOT_INITIALIZED);
}
return client;
}
示例10: onLogin
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
@Override
public void onLogin(String username, String password) throws LoginException {
Log.info("MyUserEventHandler.onLogin(" + username + ", " + password + ")");
if (username.equalsIgnoreCase("mike") && password.equalsIgnoreCase("mike")) {
Log.info("Yaaay!");
} else {
throw new LoginException(ErrorMessage.INVALID_USERNAME_ANDOR_PASSWORD);
}
}
示例11: initialize
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
public static void initialize(int writeBufferSize, int objectBufferSize) throws IOException, KryonetServerException {
Log.debug("KryonetServerInstance.initialize(" + writeBufferSize + ", " + objectBufferSize + ")");
if (server != null) {
throw new KryonetServerException(ErrorMessage.SERVER_ALREADY_INITIALIZED);
}
server = new KryonetServer(writeBufferSize, objectBufferSize);
}
示例12: getInstance
import net.dlogic.kryonet.common.constant.ErrorMessage; //导入依赖的package包/类
public static KryonetServer getInstance() throws KryonetServerException {
//Log.debug("KryonetServerInstance.getInstance()");
if (server == null) {
throw new KryonetServerException(ErrorMessage.SERVER_NOT_INITIALIZED);
}
return server;
}