(String message)
| 266 | } |
| 267 | |
| 268 | private void handleMessage(String message) |
| 269 | { |
| 270 | //System.out.println("Received from "+"server: "+message); |
| 271 | |
| 272 | String[] info = new String[0]; |
| 273 | |
| 274 | if(message != null) |
| 275 | { |
| 276 | info = message.split("&"); |
| 277 | } |
| 278 | |
| 279 | if(info.length > 0) |
| 280 | { |
| 281 | int code = Integer.parseInt(info[0]); |
| 282 | |
| 283 | switch(code) |
| 284 | { |
| 285 | case NetworkProtocol.NO_INFO: |
| 286 | { |
| 287 | |
| 288 | }break; |
| 289 | |
| 290 | case NetworkProtocol.JOIN: |
| 291 | { |
| 292 | if(info.length == 3) |
| 293 | { |
| 294 | try |
| 295 | { |
| 296 | String name = URLDecoder.decode(info[1], "UTF-8"); |
| 297 | int id = Integer.parseInt(info[2]); |
| 298 | |
| 299 | addPlayer(name, id); |
| 300 | } |
| 301 | catch(Exception e) |
| 302 | { |
| 303 | e.printStackTrace(); |
| 304 | } |
| 305 | } |
| 306 | }break; |
| 307 | |
| 308 | case NetworkProtocol.SAY_CHAT: |
| 309 | { |
| 310 | if(info.length == 3) |
| 311 | { |
| 312 | try |
| 313 | { |
| 314 | int id = Integer.parseInt(info[1]); |
| 315 | String chatMessage = URLDecoder.decode(info[2], "UTF-8"); |
| 316 | |
| 317 | addToChat(id, chatMessage); |
| 318 | } |
| 319 | catch(Exception e) |
| 320 | { |
| 321 | e.printStackTrace(); |
| 322 | } |
| 323 | } |
| 324 | }break; |
| 325 |
no test coverage detected