@Override
	/**
	 * Takes actions based on messages received
	 */
	public void receive(Message msg) {
		super.receive(msg);
		Command hdr = (Command) msg.getHeader(Command.HEADER_ID);
		switch (hdr.command) {
		case 's': // sync state
			System.out.format(
					"[%s] Received command to sync gameState from %s: %s%n",
					address, msg.getSrc(), (GameState) msg.getObject());
			if (gamePanel != null) {
				GameState new_state = (GameState) msg.getObject();
				gamePanel.gameStateChanged(new_state);
				player.gameStateChanged(new_state);
			}
			break;
		case 'i': // initialize the game
			if (!msg.getSrc().equals(address)) { // if not sent by myself
				try {
					System.out
							.format("[%s]: received initialize command, with GameState %s%n",
									address, (GameState) msg.getObject());
					start((GameState) msg.getObject());
				} catch (Exception e) {
					System.err.println("unable to start game");
					e.printStackTrace();
				}
			}
			break;
		case 'c': // process received cards
			System.out.format("[%s]: Received and setting : %s from %s%n.",
					address, (Combination) msg.getObject(), msg.getSrc());
			System.out.println("current player being "
					+ game.getGameState().getCurrentPlayer());
			NetworkPlayer p = (NetworkPlayer) game.getGameState()
					.getCurrentPlayer(); // get current player
			p.setSelectedCombination((Combination) msg.getObject()); // set his
																		// cards
			gameStateChanged(game.getGameState()); // sync to all
			break;
		case 't': // a notice that it's this player's turn
			if (gamePanel == null)
				System.out
						.format("%s is asking for a turn, but gamePanel is null!");
			else
				System.out
						.format("[%s]: %s is asking for a turn. LocalPlayerIndex is %d. State is %s%n",
								address, msg.getSrc(),
								gamePanel.getLocalPlayerIndex(),
								gamePanel.state);
			break;
		}
	}