public static MessageType deserializeHeader(final ByteBuf buf) {

		// checking the version
		int version = buf.readInt();
		Preconditions.checkState(version == VERSION,
				"Version Mismatch:  Found " + version + ", Expected: " + VERSION + '.');

		// fetching the message type
		int msgType = buf.readInt();
		MessageType[] values = MessageType.values();
		Preconditions.checkState(msgType >= 0 && msgType < values.length,
				"Illegal message type with index " + msgType + '.');
		return values[msgType];
	}
public static MessageType deserializeHeader ( final ByteBuf buf ) { int version = buf . readInt ( ) ; Preconditions . checkState ( version == VERSION , "Version Mismatch:  Found " + version + ", Expected: " + VERSION + '.' ) ; int msgType = buf . readInt ( ) ; MessageType [ ] values = MessageType . values ( ) ; Preconditions . checkState ( msgType >= 0 && msgType < values . length , "Illegal message type with index " + msgType + '.' ) ; return values [ msgType ] ; }
De-serializes the header and returns the {@link MessageType}.
<pre>
<b>The buffer is expected to be at the header position.</b>
</pre>
@param buf						The {@link ByteBuf} containing the serialized header.
@return							The message type.
@throws IllegalStateException	If unexpected message version or message type.