Пример #1
0
        public UpdateClientPeriodic(UpdateClient updateClient, ILog log)
        {
            _updateClient = updateClient;
            _log = log;

            //_updateTimerPlayers = new Timer((args) =>
            //{
            //    try
            //    {
            //        if (_updateClient.Connected)
            //        {
            //            _updateClient.SendCommand(UpdateClient.CommandType.Players);

            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        _log.Error(e);
            //    }
            //});

            //_updateTimerBans = new Timer((args) =>
            //{
            //    try
            //    {
            //        if (_updateClient.Connected)
            //        {
            //            _updateClient.SendCommand(UpdateClient.CommandType.Bans);

            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        _log.Error(e);
            //    }
            //});

            //_updateTimerAdmins = new Timer((args) =>
            //{
            //    try
            //    {
            //        if (_updateClient.Connected)
            //        {
            //            _updateClient.SendCommand(UpdateClient.CommandType.Admins);

            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        _log.Error(e);
            //    }
            //});

            _updateTimerKeepAlive = new Timer(args =>
            {
                try
                {
                    if (!_updateClient.Connected && !_updateClient.Disposed)
                    {
                        _updateClient.Disconnect();
                        _updateClient.Connect();
                    }
                }
                catch (Exception e)
                {
                    _log.Error(e);
                }
            });
        }