public int publish(String event) {

		// event = eventTypes.event[1];
		String input = null;
		String inputAndUnit = null;

		// while loop to get temperature
		while (true) {
			generateTemp();
			getTemp();
			input = generateString;
			inputAndUnit = input + event;

			System.out.println("Actual temperature: " + input);

			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				Thread.currentThread().interrupt();
				e.printStackTrace();
			}
			DatagramPacket data = new DatagramPacket(inputAndUnit.getBytes(),
					inputAndUnit.length(), group, 8885);
			try {
				temp = Integer.parseInt(input);
				if (temp == 0) {
					break;
				}
				if (13 < temp && temp < 25) {
					// break;
				} else
					System.out.println("Error. "
							+ "Temperature should be between 14 and 24");
			} catch (NumberFormatException n) {
				System.out.println("Error. Not an integer");
			}
			try {
				// broadcast the data
				tempClient.send(data);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
		return temp;
	}