(String message, LobbyPlayer player)
| 210 | } |
| 211 | |
| 212 | public synchronized void handleMessage(String message, LobbyPlayer player) |
| 213 | { |
| 214 | String[] info = new String[0]; |
| 215 | |
| 216 | if(message != null) |
| 217 | { |
| 218 | info = message.split("&"); |
| 219 | } |
| 220 | |
| 221 | if(info.length > 0) |
| 222 | { |
| 223 | int code = Integer.parseInt(info[0]); |
| 224 | |
| 225 | if(code != NetworkProtocol.NO_INFO) |
| 226 | { |
| 227 | System.out.println("Received from "+player.getID()+": "+message); |
| 228 | } |
| 229 | |
| 230 | switch(code) |
| 231 | { |
| 232 | case NetworkProtocol.NO_INFO: |
| 233 | { |
| 234 | |
| 235 | }break; |
| 236 | |
| 237 | case NetworkProtocol.SAY_CHAT: |
| 238 | { |
| 239 | if(info.length == 2) |
| 240 | { |
| 241 | String chatMessage = info[1]; |
| 242 | |
| 243 | sendChat(player.getID(), chatMessage); |
| 244 | } |
| 245 | }break; |
| 246 | |
| 247 | case NetworkProtocol.ROOM_STATUS: |
| 248 | { |
| 249 | if(info.length == 3) |
| 250 | { |
| 251 | int gameMode = Integer.parseInt(info[1]); |
| 252 | int numPlayers = Integer.parseInt(info[2]); |
| 253 | |
| 254 | Room room = player.getRoom(); |
| 255 | |
| 256 | if(room != null) |
| 257 | { |
| 258 | room.updateRoom(numPlayers, gameMode); |
| 259 | updateRoom(player.getRoom()); |
| 260 | } |
| 261 | } |
| 262 | }break; |
| 263 | |
| 264 | case NetworkProtocol.CREATE_ROOM: |
| 265 | { |
| 266 | if(info.length == 3) |
| 267 | { |
| 268 | String roomName = info[1]; |
| 269 | int portNumber = Integer.parseInt(info[2]); |
no test coverage detected