MCPcopy Create free account
hub / github.com/catabriga/graphwar / handleMessage

Method handleMessage

src/GlobalServer/GlobalServer.java:212–326  ·  view source on GitHub ↗
(String message, LobbyPlayer player)

Source from the content-addressed store, hash-verified

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]);

Callers 1

runMethod · 0.45

Calls 12

sendChatMethod · 0.95
updateRoomMethod · 0.95
updateRoomMethod · 0.95
tryConnectionMethod · 0.95
sendNewRoomMethod · 0.95
sendRoomInvalidMethod · 0.95
removeRoomMethod · 0.95
removePlayerMethod · 0.95
getRoomMethod · 0.80
setRoomMethod · 0.80
getIDMethod · 0.45
getIpAddressMethod · 0.45

Tested by

no test coverage detected