Esempio n. 1
0
 public void Dispose()
 {
     if (!mIsDisposed)
     {
         Client      = null;
         mIsDisposed = true;
         if (pipeStream != null)
         {
             pipeStream.Dispose();
             pipeStream = null;
         }
     }
 }
Esempio n. 2
0
 public void Initialization(IServer server, Action <ISession> setting)
 {
     Server                        = server;
     mBaseNetStream                = new Buffers.PipeStream(this.BufferPool, server.Config.LittleEndian, server.Config.Encoding);
     mBaseNetStream.Encoding       = Server.Config.Encoding;
     mBaseNetStream.LittleEndian   = server.Config.LittleEndian;
     mBaseNetStream.FlashCompleted = OnWriterFlash;
     mBaseNetStream.Socket         = this.Socket;
     Authentication                = AuthenticationType.None;
     if (setting != null)
     {
         setting(this);
     }
 }
Esempio n. 3
0
 public void Initialization(IServer server, Action <ISession> setting)
 {
     Server                        = server;
     mBaseNetStream                = new Buffers.PipeStream(this.SendBufferPool, server.Options.LittleEndian, server.Options.Encoding);
     mBaseNetStream.Encoding       = Server.Options.Encoding;
     mBaseNetStream.LittleEndian   = server.Options.LittleEndian;
     mBaseNetStream.FlashCompleted = OnWriterFlash;
     mBaseNetStream.Socket         = this.Socket;
     Authentication                = AuthenticationType.None;
     SendEventArgs                 = new SocketAsyncEventArgsX();
     ReceiveEventArgs              = new SocketAsyncEventArgsX();
     if (setting != null)
     {
         setting(this);
     }
 }
Esempio n. 4
0
        private void loadChunkedData(PipeStream stream)
        {
Next:
            string line;

            if (chunkeLength == 0)
            {
                if (!stream.TryReadWith(HeaderTypeFactory.LINE_BYTES, out line))
                {
                    return;
                }
                chunkeLength = int.Parse(line, System.Globalization.NumberStyles.HexNumber);
                if (chunkeLength == 0)
                {
                    stream.ReadFree(2);
                    var item = response;
                    pipeStream.Flush();
                    item.Stream = pipeStream;
                    response    = null;
                    pipeStream  = null;
                    Completed?.Invoke(Client, item);
                    return;
                }
                response.Length += chunkeLength;
            }
            else if (chunkeLength == -1)
            {
                if (stream.TryReadWith(HeaderTypeFactory.LINE_BYTES, out line))
                {
                    chunkeLength = 0;
                }
                else
                {
                    return;
                }
            }
            if (chunkeLength > 0)
            {
                if (pipeStream == null)
                {
                    pipeStream = new PipeStream();
                }
                while (true)
                {
                    byte[] buffer = HttpParse.GetByteBuffer();
                    int    count  = buffer.Length;
                    if (count > chunkeLength)
                    {
                        count = chunkeLength;
                    }
                    int read = stream.Read(buffer, 0, count);
                    if (read == 0)
                    {
                        return;
                    }
                    pipeStream.Write(buffer, 0, read);
                    chunkeLength -= read;
                    if (chunkeLength == 0)
                    {
                        chunkeLength = -1;
                        break;
                    }
                }
            }
            if (stream.Length > 0)
            {
                goto Next;
            }
        }
Esempio n. 5
0
 public abstract object Deserialization(BeetleX.Buffers.PipeStream stream, Type type, int length);
Esempio n. 6
0
        private void loadChunkedData(PipeStream stream)
        {

        Next:
            string line;
            if (chunkeLength > 0)
            {
                if (pipeStream == null)
                    pipeStream = new PipeStream();
                while (true)
                {
                    byte[] buffer = HttpParse.GetByteBuffer();
                    int count = buffer.Length;
                    if (count > chunkeLength)
                        count = chunkeLength;
                    int read = stream.Read(buffer, 0, count);
                    if (read == 0)
                        return;
                    pipeStream.Write(buffer, 0, read);
                    chunkeLength -= read;
                    if (chunkeLength == 0)
                    {
                        chunkeLength = 0;
                        break;
                    }
                }
            }
            else
            {
                if (!stream.TryReadWith(HeaderTypeFactory.LINE_BYTES, out line))
                    return;
                if (string.IsNullOrEmpty(line))
                {
                    if (end)
                    {
                        var item = response;
                        pipeStream.Flush();
                        item.Stream = pipeStream;
                        response = null;
                        pipeStream = null;
                        end = false;
                        Completed?.Invoke(Client, item);
                        return;
                    }
                    else
                    {
                        goto Next;
                    }
                }
                else
                {
                    try
                    {
                        chunkeLength = int.Parse(line, System.Globalization.NumberStyles.HexNumber);
                        if (chunkeLength == 0)
                        {
                            end = true;
                        }
                        else
                            response.Length += chunkeLength;
                    }
                    catch (Exception e_)
                    {
                        throw e_;
                    }
                }
            }
            if (stream.Length > 0)
                goto Next;
        }
Esempio n. 7
0
 public LockFreeImpl(PipeStream stream)
 {
     mStream = stream;
 }