private void Initialize() { _acceptSaeaPool = new SaeaPool(16, 32, () => { var saea = new SaeaAwaitable(); return(saea); }, (saea) => { try { saea.Saea.AcceptSocket = null; saea.Saea.SetBuffer(0, 0); saea.Saea.RemoteEndPoint = null; saea.Saea.SocketFlags = SocketFlags.None; } catch (Exception ex) { Loger.Error(ex.Message, ex); } }); _handleSaeaPool = new SaeaPool(1024, int.MaxValue, () => { var saea = new SaeaAwaitable(); return(saea); }, (saea) => { try { saea.Saea.AcceptSocket = null; saea.Saea.SetBuffer(EmptyArray, 0, 0); saea.Saea.RemoteEndPoint = null; saea.Saea.SocketFlags = SocketFlags.None; } catch (Exception ex) { Loger.Error(ex.Message, ex); } }); _sessionPool = new SessionPool(1024, int.MaxValue, () => { var session = new TcpSocketSaeaSession(_configuration, _configuration.BufferManager, _handleSaeaPool, _dispatcher, this); return(session); }, (session) => { try { session.Clear(); } catch (Exception ex) { Loger.Error(ex.Message, ex); } }); }
private void Initialize() { _bufferManager = new GrowingByteBufferManager(_configuration.InitialPooledBufferCount, _configuration.ReceiveBufferSize); _saeaPool = new SaeaPool(1024, int.MaxValue, () => { var saea = new SaeaAwaitable(); return(saea); }, (saea) => { try { saea.Saea.AcceptSocket = null; saea.Saea.SetBuffer(EmptyArray, 0, 0); saea.Saea.RemoteEndPoint = null; saea.Saea.SocketFlags = SocketFlags.None; } catch (Exception ex) { _log.Error(ex.Message, ex); } }); }
public TcpSocketSaeaSession( TcpSocketSaeaServerConfiguration configuration, ISegmentBufferManager bufferManager, SaeaPool saeaPool, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServer server) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (bufferManager == null) { throw new ArgumentNullException("bufferManager"); } if (saeaPool == null) { throw new ArgumentNullException("saeaPool"); } if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } if (server == null) { throw new ArgumentNullException("server"); } _configuration = configuration; _bufferManager = bufferManager; _saeaPool = saeaPool; _dispatcher = dispatcher; _server = server; if (_receiveBuffer == default(ArraySegment <byte>)) { _receiveBuffer = _bufferManager.BorrowBuffer(); } _receiveBufferOffset = 0; }
public TcpSocketSaeaSession( TcpSocketSaeaServerConfiguration configuration, IBufferManager bufferManager, SaeaPool saeaPool, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServer server) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (bufferManager == null) { throw new ArgumentNullException("bufferManager"); } if (saeaPool == null) { throw new ArgumentNullException("saeaPool"); } if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } if (server == null) { throw new ArgumentNullException("server"); } _configuration = configuration; _bufferManager = bufferManager; _saeaPool = saeaPool; _dispatcher = dispatcher; _server = server; _receiveBuffer = _bufferManager.BorrowBuffer(); _sessionBuffer = _bufferManager.BorrowBuffer(); _sessionBufferCount = 0; }
private void Initialize() { _saeaPool = new SaeaPool(1024, int.MaxValue, () => { var saea = new SaeaAwaitable(); return(saea); }, (saea) => { try { saea.Saea.AcceptSocket = null; saea.Saea.SetBuffer(EmptyArray, 0, 0); saea.Saea.RemoteEndPoint = null; saea.Saea.SocketFlags = SocketFlags.None; } catch (Exception ex) { Loger.Error(ex.Message, ex); } }); }
private void Initialize() { _saeaPool = new SaeaPool( () => { var saea = new SaeaAwaitable(); return(saea); }, (saea) => { try { saea.Saea.AcceptSocket = null; saea.Saea.SetBuffer(EmptyArray, 0, 0); saea.Saea.RemoteEndPoint = null; saea.Saea.SocketFlags = SocketFlags.None; } catch (Exception ex) // initialize SAEA error occurred { _log.Error(ex.Message, ex); } }) .Initialize(256); }