Exemple #1
0
 public async Task OnSessionClosed(TcpSocketRioSession session)
 {
     if (_onSessionClosed != null)
     {
         await _onSessionClosed(session);
     }
 }
Exemple #2
0
        public TcpSocketRioSession GetSession(string sessionKey)
        {
            TcpSocketRioSession session = null;

            _sessions.TryGetValue(sessionKey, out session);
            return(session);
        }
Exemple #3
0
 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));
        }
Exemple #5
0
        public async Task CloseSession(string sessionKey)
        {
            TcpSocketRioSession session = null;

            if (_sessions.TryGetValue(sessionKey, out session))
            {
                await session.Close();
            }
        }
Exemple #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);
            }
        }
Exemple #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);
                    }
                }
            }
        }
Exemple #8
0
 public async Task SendToAsync(TcpSocketRioSession session, byte[] data)
 {
     await SendToAsync(session, data, 0, data.Length);
 }
 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);
     }
 }
Exemple #10
0
 public async Task SendToAsync(TcpSocketRioSession session, byte[] data)
 {
     await SendToAsync(session, data, 0, data.Length);
 }
Exemple #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);
                    }
                }
            }
        }
 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);
 }