Timer() public method

public Timer ( ) : void
return void
Ejemplo n.º 1
0
        public void SecondTimer()
        {
            // ip cache
            lock (IPs)
                while (IPs.Count > MAX_CACHE)
                {
                    DhtContact entry = IPs.Last.Value;
                    IPTable.Remove(entry.CacheHash());
                    IPs.RemoveLast();
                }

            // save cache
            if (Core.TimeNow > NextSave)
            {
                if (Network.IsLookup)
                {
                    Network.Lookup.Save(Core);
                }
                else
                {
                    Core.User.Save();
                }

                NextSave = Core.TimeNow.AddMinutes(5);
            }


            // if unresponsive
            if (!Network.Responsive)
            {
                Retry.Timer();

                if (Network.IsLookup)
                {
                    LoookupBootstrap();
                }
                else
                {
                    OpBootstrap();
                }
            }

            // send broadcast in lan mode every 20 secs
            if (Network.LanMode)//&& !IsLookup) //crit re-enable?
            {
                // if disconnected from LAN, once reconnected, establishing should be < 20 secs
                if (BroadcastTimeout <= 0)
                {
                    Ping ping = new Ping();
                    ping.Source = Network.GetLocalSource();
                    Network.LanControl.SendTo(ping);

                    BroadcastTimeout = 20;
                }
                else
                {
                    BroadcastTimeout--;
                }
            }
        }
Ejemplo n.º 2
0
        void OpBootstrap()
        {
            OpCore lookup = Core.Context.Lookup;

            // find operation nodes through global net at expanding intervals
            // called from operation network's bootstrap
            if (lookup != null &&
                Core.User.Settings.OpAccess != AccessType.Secret &&
                lookup.Network.Responsive)
            {
                LookupearchInterval.Timer();

                if (Core.TimeNow > NextLookupSearch)
                {
                    NextLookupSearch = LookupearchInterval.NextTry;

                    Network.UpdateLog("general", "Looking for " + Core.User.Settings.Operation);

                    lookup.RunInCoreAsync(delegate()
                    {
                        LookupService service = lookup.GetService(ServiceIDs.Lookup) as LookupService;
                        service.LookupCache.Search(Network.OpID, null, Search_FoundLookup);
                    });
                }
            }

            TryWebCache();

            TryIPCache();
        }