(String message)
| 89 | } |
| 90 | |
| 91 | private void handleMessage(String message) |
| 92 | { |
| 93 | String[] info = new String[0]; |
| 94 | |
| 95 | if(message != null) |
| 96 | { |
| 97 | info = message.split("&"); |
| 98 | } |
| 99 | |
| 100 | if(info.length > 0) |
| 101 | { |
| 102 | int code = Integer.parseInt(info[0]); |
| 103 | |
| 104 | switch(code) |
| 105 | { |
| 106 | case NetworkProtocol.CREATE_ROOM: |
| 107 | { |
| 108 | if(info.length == 5) |
| 109 | { |
| 110 | try |
| 111 | { |
| 112 | String roomName = URLDecoder.decode(info[1], "UTF-8"); |
| 113 | int roomID = Integer.parseInt(info[2]); |
| 114 | // String ipAddress = URLDecoder.decode(info[3], "UTF-8"); |
| 115 | // int port = Integer.parseInt(info[4]); |
| 116 | |
| 117 | if(this.roomName.compareTo(roomName) == 0) |
| 118 | { |
| 119 | this.roomListed = true; |
| 120 | this.roomID = roomID; |
| 121 | } |
| 122 | } |
| 123 | catch(Exception e) |
| 124 | { |
| 125 | e.printStackTrace(); |
| 126 | } |
| 127 | } |
| 128 | }break; |
| 129 | |
| 130 | case NetworkProtocol.LIST_ROOMS: |
| 131 | { |
| 132 | if(info.length >= 2) |
| 133 | { |
| 134 | int numRooms = Integer.parseInt(info[1]); |
| 135 | |
| 136 | this.roomListed = false; |
| 137 | for(int i=0; i<numRooms; i++) |
| 138 | { |
| 139 | try |
| 140 | { |
| 141 | String roomName = URLDecoder.decode(info[2+6*i], "UTF-8"); |
| 142 | int roomID = Integer.parseInt(info[3+6*i]); |
| 143 | // String ipAddress = URLDecoder.decode(info[4+6*i], "UTF-8"); |
| 144 | // int port = Integer.parseInt(info[5+6*i]); |
| 145 | // int mode = Integer.parseInt(info[6+6*i]); |
| 146 | // int numPlayers = Integer.parseInt(info[7+6*i]); |
| 147 | |
| 148 | if(this.roomName.compareTo(roomName) == 0) |
no test coverage detected