public SSDP(IPEndPoint LocalEP, int Expiration) { InstanceTracker.Add(this); this.LifeTimeHandler = new Intel.UPNP.LifeTimeMonitor.LifeTimeHandler(this.SearchTimerSink); this.SearchTimer.OnExpired += this.LifeTimeHandler; this.boundto = LocalEP; this.SSDP_EXPIRATION = Expiration; int minValue = (int)((this.SSDP_EXPIRATION * 0.25) * 1000.0); int maxValue = (int)((this.SSDP_EXPIRATION * 0.45) * 1000.0); this.MainBuffer = new byte[0x1000]; this.R_Ep = new IPEndPoint(0L, 0); this.ReceiveSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.UnicastSendSocket = this.ReceiveSocket; this.ReceiveSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); this.ReceiveSocket.Bind(LocalEP); this.ReceiveSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.255.255.250"), this.LocalIPEndPoint.Address)); this.NotifyTimer.OnElapsed += new SafeTimer.TimeElapsedHandler(this.__NotifyCheck); this.NotifyTimer.Interval = this.RND.Next(minValue, maxValue); this.NotifyTimer.AutoReset = true; this.NotifyTimer.Start(); this.Receiver = this.ReceiveSocket.BeginReceiveFrom(this.MainBuffer, 0, 0x1000, SocketFlags.None, ref this.R_Ep, new AsyncCallback(this.HandleReceive), null); }
protected void InitMonitor() { this.LifeTimeHandler = new Intel.UPNP.LifeTimeMonitor.LifeTimeHandler(this.LifeTimeSink); this.t.OnExpired += this.LifeTimeHandler; }