Exemplo n.º 1
0
        public override StringPackageInfo ResolvePackage(IBufferStream bufferStream)
        {
            long   len     = bufferStream.Length;
            string StrRecv = bufferStream.ReadString((int)len, Encoding.ASCII);

            OnPackageReceived?.Invoke(this, StrRecv);
            bufferStream.Clear();
            return(null);
        }
        public override TPackageInfo ResolvePackage(IBufferStream bufferStream)
        {
            int            num        = (int)bufferStream.Length;
            string         headerData = bufferStream.ReadString(num, HeaderEncoding);
            HttpHeaderInfo header     = new HttpHeaderInfo();

            MimeHeaderHelper.ParseHttpHeader(headerData, header);
            IReceiveFilter <TPackageInfo> bodyReceiveFilter = GetBodyReceiveFilter(header, num);

            if (bodyReceiveFilter != null)
            {
                base.NextReceiveFilter = bodyReceiveFilter;
                bufferStream.Clear();
                return(default(TPackageInfo));
            }
            return(ResolveHttpPackageWithoutBody(header));
        }
        /// <summary>
        /// Resolves the package binary data to package instance
        /// </summary>
        /// <param name="bufferStream">The received buffer stream.</param>
        /// <returns>the resolved package instance</returns>
        public override TPackageInfo ResolvePackage(IBufferStream bufferStream)
        {
            var length = (int)bufferStream.Length;

            string headerData = bufferStream.ReadString(length, HeaderEncoding);

            var header = new HttpHeaderInfo();

            MimeHeaderHelper.ParseHttpHeader(headerData, header);

            var nextReceiveFilter = GetBodyReceiveFilter(header, length);

            if (nextReceiveFilter != null)
            {
                NextReceiveFilter = nextReceiveFilter;
                bufferStream.Clear();
                return(default(TPackageInfo));
            }

            return(ResolveHttpPackageWithoutBody(header));
        }