private void listenForMessages()
	{
	
		// loop and read input
		while (true)
		{
			// get message from client
			final String received = receiveMessage();

			if (received == null)
				break;
						
			// we received a message from the client, now parse it and decide on
			// how to react
			try
			{			
				// parse json data sent to server
				final JSONObject jsonMessage = new JSONObject(received);
				final int action = jsonMessage.getInt(Message.Key.ACTION);

				// action defines the reason why the client sent us something
				switch (action)
				{
				case Message.Action.REQUEST_ARTICLE:
					handleClientRequestedArticle(jsonMessage);
					break;
				case Message.Action.SEND_ARTICLE:
					handleClientSentArticle(jsonMessage);
					break;
				case Message.Action.CLIENT_ARTICLE_RECEIVED:
					handleClientSentArticleReceived(jsonMessage);
					break;
				case Message.Action.CLIENT_SEND_ARTICLE_IDS:
					handleClientSentArticleIds(jsonMessage);
					break;
				case Message.Action.CLIENT_STORE_STRATUS_ID:
					handleClientSentStratusId(jsonMessage);
					break;
				default:
					Logger.log("@DistripediaWorker#listenForMessages: "
							+ "message action not understood: " + action);
				}
			} catch (JSONException e)
			{
				// json malformed
				e.printStackTrace();
			}
		}
	}