private void HandleTimeout(LifeTimeMonitor sender, object obj) { if (this.OnFailed != null) { this.OnFailed(this, new Uri(this.DUrl), new Exception("Timeout occured trying to fetch description documents")); } }
private void DeviceLifeTimeClockSink(LifeTimeMonitor sender, object obj) { DeviceInfo info; lock (this.deviceTableLock) { if (!this.deviceTable.ContainsKey(obj)) { return; } info = (DeviceInfo)this.deviceTable[obj]; this.deviceTable.Remove(obj); this.deviceUpdateClock.Remove(obj); if (this.activeDeviceList.Contains(info.Device)) { this.activeDeviceList.Remove(info.Device); } else { info.Device = null; } } if (info.Device != null) { info.Device.Removed(); } if (info.Device != null) { info.Device.Removed(); this.OnDeviceExpiredEvent.Fire(this, info.Device); } }
public NetworkInfo(InterfaceHandler onNewInterfaceSink) { this.OnNewInterfaceEvent = new WeakEvent(); this.OnInterfaceDisabledEvent = new WeakEvent(); this.InterfacePoller = new LifeTimeMonitor(); this.AddressTable = new ArrayList(); InstanceTracker.Add(this); this.InterfacePoller.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.PollInterface); this.HostName = Dns.GetHostName(); IPHostEntry hostByName = Dns.GetHostByName(this.HostName); this.AddressTable = new ArrayList(hostByName.AddressList); if (!this.AddressTable.Contains(IPAddress.Loopback)) { this.AddressTable.Add(IPAddress.Loopback); } if (onNewInterfaceSink != null) { this.OnNewInterface += onNewInterfaceSink; foreach (IPAddress address in this.AddressTable) { this.OnNewInterfaceEvent.Fire(this, address); } } this.InterfacePoller.Add(this, NetworkPollSeconds); }
private void PollInterface(LifeTimeMonitor sender, object obj) { try { ArrayList list = new ArrayList(Dns.GetHostByName(this.HostName).AddressList); ArrayList addressTable = this.AddressTable; this.AddressTable = list; if (!this.AddressTable.Contains(IPAddress.Loopback)) { this.AddressTable.Add(IPAddress.Loopback); } foreach (IPAddress address in list) { if (!addressTable.Contains(address)) { this.OnNewInterfaceEvent.Fire(this, address); } } foreach (IPAddress address2 in addressTable) { if (!list.Contains(address2)) { this.OnInterfaceDisabledEvent.Fire(this, address2); } } } catch (Exception exception) { EventLogger.Log(exception); } this.InterfacePoller.Add(this, NetworkPollSeconds); }
public MiniWebServer(Uri BaseURL) { this.IdleTimeout = true; this.KeepAliveTimer = new LifeTimeMonitor(); this.SessionTimer = new LifeTimeMonitor(); this.SessionTable = new Hashtable(); this.OnSessionEvent = new WeakEvent(); this.OnReceiveEvent = new WeakEvent(); this.OnHeaderEvent = new WeakEvent(); InstanceTracker.Add(this); this.SessionTimer.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.SessionTimerSink); this.KeepAliveTimer.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.KeepAliveSink); string host = BaseURL.Host; if (BaseURL.HostNameType == UriHostNameType.Dns) { throw new MiniWebServerException("Uri must explicitly define IP Address"); } IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(host), BaseURL.Port); this.endpoint_local = localEP; this.MainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.MainSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); this.MainSocket.Bind(localEP); this.MainSocket.Listen(0x19); this.MainSocket.BeginAccept(new AsyncCallback(this.Accept), null); this.KeepAliveTimer.Add(false, 7); }
private void SearchTimerSink(LifeTimeMonitor sender, object obj) { SearchStruct struct2 = (SearchStruct)obj; if (this.OnSearch != null) { this.OnSearch(struct2.ST, struct2.Source, struct2.Local); } }
public UPnPModeratedStateVariable(string VarName, Type VarType, bool SendEvents) : base(VarName, VarType, SendEvents) { this.Accumulator = new DefaultAccumulator(); this.PendingObject = null; this.Seconds = 0.0; this.PendingEvents = 0; this.t = new LifeTimeMonitor(); this.InitMonitor(); }
public UPnPModeratedStateVariable(string VarName, object VarValue, string[] AllowedValues) : base(VarName, VarValue, AllowedValues) { this.Accumulator = new DefaultAccumulator(); this.PendingObject = null; this.Seconds = 0.0; this.PendingEvents = 0; this.t = new LifeTimeMonitor(); this.InitMonitor(); }
public UPnPControlPoint() { this.CreateTable = Hashtable.Synchronized(new Hashtable()); this.SSDPTable = Hashtable.Synchronized(new Hashtable()); this.NetInfo = new NetworkInfo(new NetworkInfo.InterfaceHandler(this.NewInterface)); this.SyncData = ArrayList.Synchronized(new ArrayList()); this.SSDPSessions = Hashtable.Synchronized(new Hashtable()); this.Lifetime = new LifeTimeMonitor(); this.Lifetime.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.HandleExpired); }
private void KeepAliveSink(LifeTimeMonitor sender, object obj) { if (this.IdleTimeout && (((int)obj) == this.GetHashCode())) { this.ForceCloseSession(); if (this.OnInactiveClosed != null) { this.OnInactiveClosed(this); } } }
protected void LifeTimeSink(LifeTimeMonitor sender, object Obj) { lock (this) { if (this.PendingEvents > 1) { base.Value = this.PendingObject; } this.PendingObject = this.Accumulator.Reset(); this.PendingEvents = 0; } }
private void HandleExpired(LifeTimeMonitor sender, object Obj) { if (Obj.GetType().FullName == "Intel.UPNP.SSDPSession") { ((SSDPSession)Obj).Close(); this.SSDPSessions.Remove(Obj); } if (Obj.GetType().FullName == "Intel.UPNP.UPnPDeviceFactory") { ((UPnPDeviceFactory)Obj).Shutdown(); this.CreateTable.Remove(Obj); } }
public UPnPControlPoint(NetworkInfo ni) { this.CreateTable = Hashtable.Synchronized(new Hashtable()); this.SSDPTable = Hashtable.Synchronized(new Hashtable()); this.NetInfo = ni; foreach (IPAddress address in this.NetInfo.GetLocalAddresses()) { this.NewInterface(this.NetInfo, address); } this.NetInfo.OnNewInterface += new NetworkInfo.InterfaceHandler(this.NewInterface); this.SyncData = ArrayList.Synchronized(new ArrayList()); this.SSDPSessions = Hashtable.Synchronized(new Hashtable()); this.Lifetime = new LifeTimeMonitor(); this.Lifetime.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.HandleExpired); }
public UPnPDeviceFactory(Uri DescLocation, int MaxSeconds, UPnPDeviceHandler deviceCB, UPnPDeviceFailedHandler failedCB) { this.Lifetime = new LifeTimeMonitor(); InstanceTracker.Add(this); this.r = new HTTPRequest(); this.r.OnResponse += new HTTPRequest.RequestHandler(this.HandleRequest); this.CBLock = new object(); this.OnDevice = (UPnPDeviceHandler)Delegate.Combine(this.OnDevice, deviceCB); this.OnFailed = (UPnPDeviceFailedHandler)Delegate.Combine(this.OnFailed, failedCB); this.DUrl = DescLocation.ToString(); this.MaxAge = MaxSeconds; this.ExpiredHandler = new LifeTimeMonitor.LifeTimeHandler(this.HandleTimeout); this.Lifetime.OnExpired += this.ExpiredHandler; this.Lifetime.Add(DateTime.Now, 30); this.r.PipelineRequest(DescLocation, null); }
private void DeviceUpdateClockSink(LifeTimeMonitor sender, object obj) { lock (this.deviceTableLock) { if (this.deviceTable.ContainsKey(obj)) { DeviceInfo info = (DeviceInfo)this.deviceTable[obj]; if (info.PendingBaseURL != null) { info.BaseURL = info.PendingBaseURL; info.MaxAge = info.PendingMaxAge; info.SourceEP = info.PendingSourceEP; info.LocalEP = info.PendingLocalEP; info.NotifyTime = DateTime.Now; info.Device.UpdateDevice(info.BaseURL, info.LocalEP.Address); this.deviceTable[obj] = info; this.deviceLifeTimeClock.Add(info.UDN, info.MaxAge); } } } }
private void KeepAliveSink(LifeTimeMonitor sender, object obj) { if (this.IdleTimeout) { ArrayList list = new ArrayList(); lock (this.SessionTable) { IDictionaryEnumerator enumerator = this.SessionTable.GetEnumerator(); while (enumerator.MoveNext()) { if (((HTTPSession)enumerator.Value).Monitor.IsTimeout()) { list.Add(enumerator.Value); } } } foreach (HTTPSession session in list) { session.Close(); } this.KeepAliveTimer.Add(false, 7); } }
public MiniWebServer(IPEndPoint local) { this.IdleTimeout = true; this.KeepAliveTimer = new LifeTimeMonitor(); this.SessionTimer = new LifeTimeMonitor(); this.SessionTable = new Hashtable(); this.OnSessionEvent = new WeakEvent(); this.OnReceiveEvent = new WeakEvent(); this.OnHeaderEvent = new WeakEvent(); InstanceTracker.Add(this); this.SessionTimer.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.SessionTimerSink); this.KeepAliveTimer.OnExpired += new LifeTimeMonitor.LifeTimeHandler(this.KeepAliveSink); this.endpoint_local = local; this.MainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.MainSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); this.MainSocket.Bind(local); if (this.MainSocket.LocalEndPoint != null) { this.endpoint_local = (IPEndPoint)this.MainSocket.LocalEndPoint; } this.MainSocket.Listen(0x19); this.MainSocket.BeginAccept(new AsyncCallback(this.Accept), null); this.KeepAliveTimer.Add(false, 7); }
private void SessionTimerSink(LifeTimeMonitor sender, object obj) { ((HTTPSession)obj).Close(); }
public UPnPDeviceFactory() { this.Lifetime = new LifeTimeMonitor(); InstanceTracker.Add(this); this.CreateTable = Hashtable.Synchronized(new Hashtable()); }