Ejemplo n.º 1
0
        void KeepClient(UdpClient2 client)
        {
            PostEvictionCallbackRegistration cb = new PostEvictionCallbackRegistration();

            cb.EvictionCallback = (key, value, reason, state) =>
            {
                if (reason == EvictionReason.Expired)//
                {
                    _logger?.LogInformation($"UDP cache client expired:{key.ToString()},{reason.ToString()}");
                    UdpClient2 c = value as UdpClient2;
                    if (c.Active)
                    {
                        KeepClient(c);
                        _logger?.LogInformation($"UDP cache client readd:{key.ToString()}");
                    }
                }
            };
            _clientManager.Set(client.EndPoint, client, TimeSpan.FromMilliseconds(CLIENT_ACTIVE_TIMEOUT), cb);
        }
Ejemplo n.º 2
0
        UdpClient2 CreateClient(Socket sock, IPEndPoint remoteIP)
        {
            UdpClient2 udpClient2 = new UdpClient2(sock, remoteIP, _logger);

            return(udpClient2);
        }