* Take a message from this buffer. The message count decreases.
*
* @return <tt>null</tt> if buffer is empty.
*/
public RTMPMessage takeMessage() {
RTMPMessage message = messageQueue.poll();
if (message != null) {
IRTMPEvent body = message.getBody();
if (!(body instanceof IStreamData)) {
throw new RuntimeException("Expected IStreamData but got " + body);
}
messageSize -= ((IStreamData<?>) body).getData().limit();
}