Пример #1
0
        public void Write(BeetleX.Buffers.PipeStream stream)
        {
            int len = Data.Count;

            stream.Write(len.ToString("X") + "\r\n");
            stream.Write(Data.Array, Data.Offset, Data.Count);
            stream.WriteLine("");
            if (Offset == mFileResource.Length)
            {
                stream.Write("0\r\n\r\n");
            }
        }
Пример #2
0
        public void Write(BeetleX.Buffers.PipeStream stream)
        {
            int len = Data.Count;

            stream.Write(len.ToString("X"));
            stream.Write(HeaderType.LINE_BYTES);
            stream.Write(Data.Array, Data.Offset, Data.Count);
            stream.WriteLine("");
            if (Offset == mFileResource.Length)
            {
                stream.Write(HeaderType.CHUNKED_BYTES);
            }
        }
Пример #3
0
        /// <summary>
        /// düşen datayı yakalayacan metot
        /// </summary>
        /// <param name="server"></param>
        /// <param name="e"></param>
        public override void SessionReceive(IServer server, SessionReceiveEventArgs e)
        {
            try
            {
                TcpResponseModel tcpResponseModel = new TcpResponseModel()
                {
                    Result = "OK"
                };
                BeetleX.Buffers.PipeStream pipeStream = e.Stream.ToPipeStream();
                using (MemoryStream memoryStream = new MemoryStream(pipeStream.FirstBuffer.Data)) //pipeStream1.LastBuffer.Data
                    using (StreamReader reader = new StreamReader(memoryStream))
                    {
                        var data = reader.ReadToEnd();
                        if (!string.IsNullOrEmpty(data))
                        {
                            TcpInit.GetIntance().TcpDataReceived(data, null);
                        }

                        pipeStream.Write(@"{""result"":""OK""}!");
                        e.Session.Stream.Flush();
                        base.SessionReceive(server, e);
                    }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex + "TcpConsumer/SessionReceive"}");
            }
        }
Пример #4
0
 public void Write(BeetleX.Buffers.PipeStream stream)
 {
     if (GZip)
     {
         var mb = stream.Allocate(16);
         stream.Write(HeaderTypeFactory.LINE_BYTES);
         int len = stream.CacheLength;
         if (gZipStream == null)
         {
             gZipStream = new GZipStream(stream, CompressionMode.Compress, true);
         }
         gZipStream.Write(Data.Array, Data.Offset, Data.Count);
         gZipStream.Flush();
         if (Offset == mFileResource.Length)
         {
             if (gZipStream != null)
             {
                 using (stream.LockFree())
                 {
                     gZipStream.Dispose();
                 }
             }
         }
         string lenstr = (stream.CacheLength - len).ToString("X");
         mb.Full(Encoding.UTF8.GetBytes(lenstr.PadRight(16)));
     }
     else
     {
         int len = Data.Count;
         stream.Write(len.ToString("X"));
         stream.Write(HeaderTypeFactory.LINE_BYTES);
         stream.Write(Data.Array, Data.Offset, Data.Count);
     }
     stream.WriteLine("");
     if (Offset == mFileResource.Length)
     {
         stream.Write(HeaderTypeFactory.CHUNKED_BYTES);
     }
 }