private void handleMessage(Host from, Document d) {

		try {
			NodeList nl = d.getElementsByTagName("text");

			if (nl != null && nl.getLength() > 0) {
				Node n = nl.item(0);
				if (n.getParentNode().getLocalName().equals("message-v1")
						&& n.getParentNode().getParentNode().getLocalName().equals("p300")) {

					String t = n.getTextContent();
					
					

					Message m = new Message(from, null, t);

					if (MainDialog.getInstance() != null) {
						MainDialog.getInstance().lanMessageRouter.route(m);
					} else {
						D.out("LanMessageRequest: Received chat message: " + t);
					}
				} else {
					D.out("LanMessageRequest: Received unknown chat message");
				}
			} else {
				D
						.out("LanMessageRequest: Received unknown chat message without text");
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}