protected override DataFrame TryReadFrame(Stream src)
        {
            if (!header.IsInitialized)
            {
                header.TryRead(src);

                if (header.IsInitialized)
                    OnHeadRead();
                else
                    return (null);
            }

            var bytesToRead = Math.Min((UInt64)src.Length, payloadSizeRemaining);
            if (bytesToRead > 0)
            {
                var reader = new BinaryReader(src);
                var data = reader.ReadBytes((int)bytesToRead);
                payload.Add(new ArraySegment<byte>(data));
                payloadSizeRemaining -= (UInt64)data.Length;
            }

            if (payloadSizeRemaining == 0)
            {
                var payloadBytes = header.IsMasked ? ReadMaskedPayload() : ReadPayload();
                var frame = new DataFrame(payloadBytes, header.OpCode);
                Reset();
                return (frame);
            }

            return (null);
        }
Esempio n. 2
0
 public void TearDown()
 {
     _dataframe = null;
 }
Esempio n. 3
0
 public void SetUp()
 {
     _dataframe = new DataFrame();
 }