public async Task OnSessionClosed(TcpSocketRioSession session) { if (_onSessionClosed != null) { await _onSessionClosed(session); } }
public TcpSocketRioSession GetSession(string sessionKey) { TcpSocketRioSession session = null; _sessions.TryGetValue(sessionKey, out session); return(session); }
public async Task OnSessionDataReceived(TcpSocketRioSession session, byte[] data, int offset, int count) { if (_onSessionDataReceived != null) { await _onSessionDataReceived(session, data, offset, count); } }
public async Task OnSessionDataReceived(TcpSocketRioSession session, byte[] data, int offset, int count) { var text = Encoding.UTF8.GetString(data, offset, count); Console.Write(string.Format("Client : --> ")); Console.WriteLine(text); await session.SendAsync(Encoding.UTF8.GetBytes(text)); }
public async Task CloseSession(string sessionKey) { TcpSocketRioSession session = null; if (_sessions.TryGetValue(sessionKey, out session)) { await session.Close(); } }
public async Task SendToAsync(TcpSocketRioSession session, byte[] data, int offset, int count) { TcpSocketRioSession sessionFound; if (_sessions.TryGetValue(session.SessionKey, out sessionFound)) { await sessionFound.SendAsync(data, offset, count); } else { _log.WarnFormat("Cannot find session [{0}].", session); } }
private async Task Process(RioSocket acceptedSocket) { var session = new TcpSocketRioSession(_configuration, _bufferManager, acceptedSocket, _dispatcher, this); if (_sessions.TryAdd(session.SessionKey, session)) { _log.DebugFormat("New session [{0}].", session); try { await session.Start(); } finally { TcpSocketRioSession recycle; if (_sessions.TryRemove(session.SessionKey, out recycle)) { _log.DebugFormat("Close session [{0}].", recycle); } } } }
public async Task SendToAsync(TcpSocketRioSession session, byte[] data) { await SendToAsync(session, data, 0, data.Length); }
private async Task Process(RioConnectionOrientedSocket acceptedSocket) { var session = new TcpSocketRioSession(_configuration, _bufferManager, acceptedSocket, _dispatcher, this); if (_sessions.TryAdd(session.SessionKey, session)) { _log.DebugFormat("New session [{0}].", session); try { await session.Start(); } finally { TcpSocketRioSession recycle; if (_sessions.TryRemove(session.SessionKey, out recycle)) { _log.DebugFormat("Close session [{0}].", recycle); } } } }
public async Task OnSessionStarted(TcpSocketRioSession session) { //Console.WriteLine(string.Format("TCP session {0} has connected {1}.", session.RemoteEndPoint, session)); Console.WriteLine(string.Format("TCP session has connected {0}.", session)); await Task.CompletedTask; }
public async Task OnSessionClosed(TcpSocketRioSession session) { Console.WriteLine(string.Format("TCP session {0} has disconnected.", session)); await Task.CompletedTask; }
public async Task OnSessionStarted(TcpSocketRioSession session) { Console.WriteLine(string.Format("TCP session has connected {0}.", session)); await Task.CompletedTask; }
public async Task OnSessionClosed(TcpSocketRioSession session) { if (_onSessionClosed != null) await _onSessionClosed(session); }
public async Task OnSessionDataReceived(TcpSocketRioSession session, byte[] data, int offset, int count) { if (_onSessionDataReceived != null) await _onSessionDataReceived(session, data, offset, count); }