Exemplo n.º 1
0
 public async Task OnSessionClosed(TcpSocketRioSession session)
 {
     if (_onSessionClosed != null)
     {
         await _onSessionClosed(session);
     }
 }
Exemplo n.º 2
0
        public TcpSocketRioSession GetSession(string sessionKey)
        {
            TcpSocketRioSession session = null;

            _sessions.TryGetValue(sessionKey, out session);
            return(session);
        }
Exemplo n.º 3
0
 public async Task OnSessionDataReceived(TcpSocketRioSession session, byte[] data, int offset, int count)
 {
     if (_onSessionDataReceived != null)
     {
         await _onSessionDataReceived(session, data, offset, count);
     }
 }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        public async Task CloseSession(string sessionKey)
        {
            TcpSocketRioSession session = null;

            if (_sessions.TryGetValue(sessionKey, out session))
            {
                await session.Close();
            }
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        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);
                    }
                }
            }
        }
Exemplo n.º 8
0
 public async Task SendToAsync(TcpSocketRioSession session, byte[] data)
 {
     await SendToAsync(session, data, 0, data.Length);
 }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
 public async Task SendToAsync(TcpSocketRioSession session, byte[] data)
 {
     await SendToAsync(session, data, 0, data.Length);
 }
Exemplo n.º 11
0
        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);
                    }
                }
            }
        }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 public async Task OnSessionClosed(TcpSocketRioSession session)
 {
     Console.WriteLine(string.Format("TCP session {0} has disconnected.", session));
     await Task.CompletedTask;
 }
Exemplo n.º 14
0
 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);
 }