public static List <object> DecodeBuffer(RtmpContext context, ByteBuffer stream)
        {
            List <object> list = null;

            try
            {
                long num;
                bool flag;
                goto Label_0099;
Label_0009:
                num = stream.Remaining;
                if (context.CanStartDecoding(num))
                {
                    context.StartDecoding();
                    if (context.State == RtmpState.Disconnected)
                    {
                        return(list);
                    }
                    object item = Decode(context, stream);
                    if (context.HasDecodedObject)
                    {
                        if (list == null)
                        {
                            list = new List <object>();
                        }
                        list.Add(item);
                        goto Label_008A;
                    }
                    if (context.CanContinueDecoding)
                    {
                        goto Label_0099;
                    }
                }
                return(list);

Label_008A:
                if (!stream.HasRemaining)
                {
                    return(list);
                }
Label_0099:
                flag = true;
                goto Label_0009;
            }
            catch
            {
                throw;
            }
            finally
            {
                stream.Compact();
            }
            return(list);
        }
        public static ArrayList DecodeBuffer(RtmpContext context, ByteBuffer stream)
#endif
        {
            // >> HEADER[1] + CLIENT_HANDSHAKE[1536]
            // << HEADER[1] + SERVER_HANDSHAKE[1536] + CLIENT_HANDSHAKE[1536];
            // >> SERVER_HANDSHAKE[1536] + AMF[n]
#if !(NET_1_1)
            List <object> result = null;
#else
            ArrayList result = null;
#endif
            try
            {
                while (true)
                {
                    long remaining = stream.Remaining;
                    if (context.CanStartDecoding(remaining))
                    {
                        context.StartDecoding();
                    }
                    else
                    {
                        break;
                    }

                    if (context.State == RtmpState.Disconnected)
                    {
                        break;
                    }

                    object decodedObject = Decode(context, stream);
                    if (context.HasDecodedObject)
                    {
#if !(NET_1_1)
                        if (result == null)
                        {
                            result = new List <object>();
                        }
#else
                        if (result == null)
                        {
                            result = new ArrayList();
                        }
#endif
                        result.Add(decodedObject);
                    }
                    else if (context.CanContinueDecoding)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }

                    if (!stream.HasRemaining)
                    {
                        break;
                    }
                }
            }
            catch (HandshakeFailedException)
            {
                throw;
            }
            catch (Exception)
            {
                Dump(stream);
                throw;
            }
            finally
            {
                stream.Compact();
            }
            return(result);
        }
        public static ArrayList DecodeBuffer(RtmpContext context, ByteBuffer stream)
#endif
		{
			// >> HEADER[1] + CLIENT_HANDSHAKE[1536] 
			// << HEADER[1] + SERVER_HANDSHAKE[1536] + CLIENT_HANDSHAKE[1536];
			// >> SERVER_HANDSHAKE[1536] + AMF[n]
#if !(NET_1_1)
            List<object> result = null;
#else
			ArrayList result = null;
#endif
            try
            {
                while (true)
                {
                    long remaining = stream.Remaining;
                    if (context.CanStartDecoding(remaining))
                        context.StartDecoding();
                    else
                        break;

                    if (context.State == RtmpState.Disconnected)
                        break;

                    object decodedObject = Decode(context, stream);
                    if (context.HasDecodedObject)
                    {
#if !(NET_1_1)
                        if (result == null)
                            result = new List<object>();
#else
                        if (result == null)
                            result = new ArrayList();
#endif
                        result.Add(decodedObject);
                    }
                    else if (context.CanContinueDecoding)
                        continue;
                    else
                        break;

                    if (!stream.HasRemaining)
                        break;
                }
            }
            catch (HandshakeFailedException)
            {
                throw;
            }
            catch (Exception)
            {
                Dump(stream);
                throw;
            }
            finally
			{
			    stream.Compact();
			}
			return result;
		}