public static ProtocolMessage fromBytes(ByteBuffer input){
        byte mtype = input.get();
                
        switch (MessageType.fromByte(mtype)) {
        case SEND_MESSAGE:
			return SendMessageRequest.fromBytes(input);
        case CONNECTION_REQUEST:
        	return ConnectionRequest.fromBytes(input);
        case RETRIEVE_QUEUES:
        	return GetQueuesRequest.fromBytes(input);
//        case MESSAGE_RECEIVED:
//        	return MessageReceivedRequest.fromBytes(input);
        case QUEUE_MODIFICATION:
        	return QueueModificationRequest.fromBytes(input);
		case REQUEST_RESPONSE:
			return RequestResponse.fromBytes(input);
		case RETRIEVE_MESSAGE:
			return RetrieveMessageRequest.fromBytes(input);
		case RETURNED_MESSAGES:
			return RetrieveMessageResponse.fromBytes(input);
		case RETURNED_QUEUE:
			return GetQueuesResponse.fromBytes(input);
		default:
			throw new UnsupportedOperationException("That message type is not supported.");
        }
    }