public TcpSocketSaeaSession GetSession(string sessionKey) { TcpSocketSaeaSession session = null; _sessions.TryGetValue(sessionKey, out session); return(session); }
public async Task OnSessionClosed(TcpSocketSaeaSession session) { if (_onSessionClosed != null) { await _onSessionClosed(session); } }
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); } }); }
public async Task OnSessionDataReceived(TcpSocketSaeaSession session, byte[] data, int offset, int count) { if (_onSessionDataReceived != null) { await _onSessionDataReceived(session, data, offset, count); } }
public async Task CloseSession(string sessionKey) { TcpSocketSaeaSession session = null; if (_sessions.TryGetValue(sessionKey, out session)) { await session.Close(); } }
public async Task CloseSession(string sessionKey) { TcpSocketSaeaSession session = null; if (_sessions.TryGetValue(sessionKey, out session)) { await session.Close(); // parent server close session by session-key } }
public async Task SendToAsync(TcpSocketSaeaSession session, byte[] data, int offset, int count) { TcpSocketSaeaSession sessionFound; if (_sessions.TryGetValue(session.SessionKey, out sessionFound)) { await sessionFound.SendAsync(data, offset, count); } else { Loger.WarnFormat("Cannot find session [{0}].", session); } }
public async Task SendToAsync(TcpSocketSaeaSession session, byte[] data) { await SendToAsync(session, data, 0, data.Length); }
public async Task OnSessionClosed(TcpSocketSaeaSession session) { if (_onSessionClosed != null) await _onSessionClosed(session); }
public async Task OnSessionDataReceived(TcpSocketSaeaSession session, byte[] data, int offset, int count) { if (_onSessionDataReceived != null) await _onSessionDataReceived(session, data, offset, count); }
private void Initialize() { _bufferManager = new GrowingByteBufferManager(_configuration.InitialBufferAllocationCount, _configuration.ReceiveBufferSize); _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) { _log.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) { _log.Error(ex.Message, ex); } }); _sessionPool = new SessionPool(1024, int.MaxValue, () => { var session = new TcpSocketSaeaSession(_configuration, _bufferManager, _handleSaeaPool, _dispatcher, this); return session; }, (session) => { try { session.Clear(); } catch (Exception ex) { _log.Error(ex.Message, ex); } }); }
public async Task SendToAsync(TcpSocketSaeaSession session, byte[] data, int offset, int count) { TcpSocketSaeaSession sessionFound; if (_sessions.TryGetValue(session.SessionKey, out sessionFound)) { await sessionFound.SendAsync(data, offset, count); } else { _log.WarnFormat("Cannot find session [{0}].", session); } }