예제 #1
0
 public PeriodicLogger(DebugUtils.LogLevels level, int freqsec)
 {
     LogLevel  = level;
     LogAction = new PeriodicAction(TickSpan.Seconds(freqsec));
 }
예제 #2
0
        private void Run()
        {
            var buf  = new byte[65536];
            var buf2 = new byte[65536];

            try
            {
                MulticastSocket.BeginReceiveFrom(buf, 0, buf.Length, SocketFlags.None, ref MLEp, new AsyncCallback(ReceiveMulticast), buf);

                DiscoverDevices();
                Thread.Sleep(1000);
                while (!Terminated)
                {
                    try
                    {
                        DiscoverAction.Do(DiscoverDevices);

                        GetExternalAddressAction.Do(delegate
                        {
                            if (GetExternalAddressAction.Frequency.ToSeconds < 1.0)
                            {
                                GetExternalAddressAction.Frequency = TickSpan.Seconds(60 * 30);
                                GetExternalAddressAction.Start();
                            }

                            if (WANIPConnectionsCtlInfo.Count > 0)
                            {
                                ControlInfo ci;
                                lock ( WANIPConnectionsCtlInfo )
                                {
                                    ci = WANIPConnectionsCtlInfo.Values.First();
                                }
                                RequestExternalIpAddress(ci);
                            }
                        });

                        ExternalPortMappingAction.Do(delegate
                        {
                            if (ExternalPortMappingAction.Frequency.ToSeconds < 1.0)
                            {
                                ExternalPortMappingAction.Frequency = TickSpan.Seconds(LeaseMapDurationSeconds - 200);
                                ExternalPortMappingAction.Start();
                            }

                            if (WANIPConnectionsCtlInfo.Count > 0)
                            {
                                UpdatePortMapping("TCP");
                                UpdatePortMapping("UDP");
                            }
                        });

                        Thread.Sleep(1000);
                    }
                    catch (ThreadAbortException ex)
                    {
                        Logging.Log(ex);
                    }
                    catch (Exception ex)
                    {
                        Logging.Log(ex);
                    }
                }
            }
            finally
            {
                Terminated = true;
            }
        }
예제 #3
0
 public PeriodicLogger(int freqsec)
 {
     LogAction = new PeriodicAction(TickSpan.Seconds(freqsec));
     LogLevel  = DebugUtils.LogLevels.DebugData;
 }