public Message waitForMessage() throws CommunicationException
public final Message waitForMessage() throws CommunicationException
    public Message waitForMessage() throws CommunicationException    {	synchronized (this) {	    if (m_listening) {		throw new CommunicationException(		    "More than one thread called waitForMessage()");	    }	    m_listening = true;	}	try {	    final Message message;	    if (m_shuttingDown) {		shutdownComplete();		return null;	    }		    try {		m_packet.setData(m_buffer, 0, m_buffer.length);		m_socket.receive(m_packet);		final ByteArrayInputStream byteStream =		    new ByteArrayInputStream(m_buffer, 0, m_buffer.length);		final ObjectInputStream objectStream =		    new ObjectInputStream(byteStream);		message = (Message)objectStream.readObject();	    }	    catch (Exception e) {		throw new CommunicationException(		    "Error receving multicast packet", e);	    }	    if (message instanceof ShutdownMessage) {		shutdownComplete();		return null;	    }	    final String senderID = message.getSenderUniqueID();	    final long sequenceNumber = message.getSequenceNumber();	    final SequenceValue sequenceValue =		(SequenceValue)m_sequenceValues.get(senderID);	    if (sequenceValue != null) {		sequenceValue.nextValue(sequenceNumber);	    }	    else {		m_sequenceValues.put(senderID,				     new SequenceValue(sequenceNumber));	    }	    	    return message;	}	finally {	    synchronized (this) {		m_listening = false;	    }	}    }