private void RenewConnect(IAsyncResult aAsync) { try { iRequest.EndConnect(aAsync); iMutex.WaitOne(); string sid = iSubscriptionId; iMutex.ReleaseMutex(); if (sid != null) { Upnp.WriteMethodSubscribe(iWriter, iEventUri.AbsolutePath); Upnp.WriteHost(iWriter, iEventUri.Host + ":" + iEventUri.Port.ToString()); Upnp.WriteSid(iWriter, iSubscriptionId); Upnp.WriteTimeout(iWriter, kSubscriptionTimeout); iWriter.WriteFlush(); iRequest.BeginWaitForData(RenewWaitForData); } else { iRequest.Close(); iSubscribing = false; iPendingSubscribe = false; iUnsubscribing = false; iPendingUnsubscribe = false; iSubscriptionId = null; } } catch (Exception ex) { HandleSubscriptionException("RenewConnect", ex); } }
private void UnsubscribeConnect(IAsyncResult aAsync) { Trace.WriteLine(Trace.kUpnp, "Unsubscribe End Connect"); try { iRequest.EndConnect(aAsync); iMutex.WaitOne(); string sid = iSubscriptionId; iMutex.ReleaseMutex(); if (sid != null) { Upnp.WriteMethodUnsubscribe(iWriter, iEventUri.AbsolutePath); Upnp.WriteHost(iWriter, iEventUri.Host + ":" + iEventUri.Port.ToString()); Upnp.WriteSid(iWriter, sid); iWriter.WriteFlush(); Trace.WriteLine(Trace.kUpnp, "Unsubscribe Begin Wait For Data"); iRequest.BeginWaitForData(UnsubscribeWaitForData); } else { Trace.WriteLine(Trace.kUpnp, "Unsubscribe Killed"); iRequest.Close(); } } catch (Exception ex) { HandleSubscriptionException("UnsubscribeConnect", ex); } }