protected override bool DoDecode(ByteBuffer input, IProtocolDecoderOutput output)
 {
     MessageDecoderResult result;
     if (_currentDecoder == null)
     {
         IMessageDecoder[] decoders = _decoders;
         int undecodables = 0;
     
         for (int i = decoders.Length - 1; i >= 0; i --) 
         {
             IMessageDecoder decoder = decoders[i];
             int limit = input.Limit;
             int pos = input.Position;
             
             try
             {
                 result = decoder.Decodable(input);
             }
             finally
             {
                 input.Position = pos;
                 input.Limit = limit;
             }
             
             if (result == MessageDecoderResult.OK)
             {
                 _currentDecoder = decoder;
                 break;
             }
             else if(result == MessageDecoderResult.NOT_OK)
             {
                 undecodables ++;
             }
             else if (result != MessageDecoderResult.NEED_DATA)
             {
                 throw new Exception("Unexpected decode result (see your decodable()): " + result);
             }
         }
         
         if (undecodables == _decoders.Length)
         {
             // Throw an exception if all decoders cannot decode data.
             input.Position = input.Limit; // Skip data
             throw new ProtocolDecoderException(
                 "No appropriate message decoder: " + input.GetHexDump());
         }
         
         if (_currentDecoder == null)
         {
             // Decoder is not determined yet (i.e. we need more data)
             return false;
         }
     }
     
     result = _currentDecoder.Decode(input, output);
     if (result == MessageDecoderResult.OK)
     {
         _currentDecoder = null;
         return true;
     }
     else if (result == MessageDecoderResult.NEED_DATA)
     {
         return false;
     }
     else if (result == MessageDecoderResult.NOT_OK) 
     {
         throw new ProtocolDecoderException("Message decoder returned NOT_OK.");
     }
     else
     {
         throw new Exception("Unexpected decode result (see your decode()): " + result);
     }
 }