Exemplo n.º 1
0
        private async Task RunAsync()
        {
            _isPossibleUpdate = true;

            try
            {
                await Task.Delay(-1, _cts.Token);
            }
            catch
            {
            }

            _isPossibleUpdate = false;
            Close();

            try
            {
                _tcpChannel?.OnClosed();
                _udpChannel?.OnClosed();
            }
            catch
            {
            }

            _cts?.Dispose();
            _cts = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 세션이 닫혔음
        /// </summary>
        protected virtual Task OnClosed()
        {
            NetPacket poolingPacket;

            while (_receivedPacketQueue.TryReceive(out poolingPacket) == true &&
                   poolingPacket != null)
            {
                NetPool.PacketPool.Free(poolingPacket);
            }

            _cts?.Dispose();
            _cts = null;

            try
            {
                _tcpChannel?.OnClosed();
                _udpChannel?.OnClosed();
                _request.Close();
            }
            catch
            {
            }

            return(Task.CompletedTask);
        }