public void run() { /* Pre-conditions: p and game have been instantiated. Post-conditions: There will no longer be a connection to the player and the player can be removed from the game. Semantics: This method will loop while listening for messages and moves from p. When the connection to the player is lost this method will inform the game and stop looping. */ try { while ((message = p.getInput().readLine()) != null) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(message)); Document doc = builder.parse(is); Element root = doc.getDocumentElement(); // Server only deals with messages if (root.getTagName().equals("message")) { parseMessage(root); } } } catch (Exception e) { } game.removePlayer(p); }