public void Dispose() { if (!mIsDisposed) { Client = null; mIsDisposed = true; if (pipeStream != null) { pipeStream.Dispose(); pipeStream = null; } } }
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); } }
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); } }
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; } }
public abstract object Deserialization(BeetleX.Buffers.PipeStream stream, Type type, int length);
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; }
public LockFreeImpl(PipeStream stream) { mStream = stream; }