protected override void EventServerEvent(EventServerUpnp obj, EventArgsEvent e) { }
protected override void EventServerEvent(EventServerUpnp obj, EventArgsEvent e) { if (e.SubscriptionId != SubscriptionId) { // This event is for a different subscription than the current. This can happen as follows: // // 1. Events A & B are received and queued up in the event server // 2. Event A is processed and is out of sequence - an unsubscribe/resubscribe is triggered // 3. By the time B is processed, the unsubscribe/resubscribe has completed and the SID is now different // // The upshot is that this event is ignored return; } lock (iLock) { if (e.SequenceNo != iExpectedSequenceNumber) { // An out of sequence event is being processed - log, resubscribe and discard UserLog.WriteLine("EventServerEvent(ServiceConfiguration): " + SubscriptionId + " Out of sequence event received. Expected " + iExpectedSequenceNumber + " got " + e.SequenceNo); // resubscribing means that the initial event will be resent iExpectedSequenceNumber = 0; Unsubscribe(); Subscribe(); return; } else { iExpectedSequenceNumber++; } } XmlNode variable; XmlNamespaceManager nsmanager = new XmlNamespaceManager(e.Xml.NameTable); nsmanager.AddNamespace("e", kNamespaceUpnpService); bool eventConfigurationXml = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "ConfigurationXml", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } ConfigurationXml = value; eventConfigurationXml = true; } bool eventParameterXml = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "ParameterXml", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } ParameterXml = value; eventParameterXml = true; } if (eventConfigurationXml) { if (EventStateConfigurationXml != null) { try { EventStateConfigurationXml(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateConfigurationXml: " + ex); Assert.CheckDebug(false); } } } if (eventParameterXml) { if (EventStateParameterXml != null) { try { EventStateParameterXml(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateParameterXml: " + ex); Assert.CheckDebug(false); } } } if (EventState != null) { EventState(this, EventArgs.Empty); } EventHandler <EventArgs> eventInitial = null; lock (iLock) { if (!iInitialEventReceived && e.SequenceNo == 0) { iInitialEventReceived = true; eventInitial = iEventInitial; } } if (eventInitial != null) { eventInitial(this, EventArgs.Empty); } }
protected abstract void EventServerEvent(EventServerUpnp obj, EventArgsEvent e);
protected override void EventServerEvent(EventServerUpnp obj, EventArgsEvent e) { if (e.SubscriptionId != SubscriptionId) { // This event is for a different subscription than the current. This can happen as follows: // // 1. Events A & B are received and queued up in the event server // 2. Event A is processed and is out of sequence - an unsubscribe/resubscribe is triggered // 3. By the time B is processed, the unsubscribe/resubscribe has completed and the SID is now different // // The upshot is that this event is ignored return; } lock (iLock) { if (e.SequenceNo != iExpectedSequenceNumber) { // An out of sequence event is being processed - log, resubscribe and discard UserLog.WriteLine("EventServerEvent(ServiceDelay): " + SubscriptionId + " Out of sequence event received. Expected " + iExpectedSequenceNumber + " got " + e.SequenceNo); // resubscribing means that the initial event will be resent iExpectedSequenceNumber = 0; Unsubscribe(); Subscribe(); return; } else { iExpectedSequenceNumber++; } } XmlNode variable; XmlNamespaceManager nsmanager = new XmlNamespaceManager(e.Xml.NameTable); nsmanager.AddNamespace("e", kNamespaceUpnpService); bool eventDelay = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "Delay", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { Delay = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse Delay with value {1}", DateTime.Now, value)); } eventDelay = true; } bool eventDelayMinimum = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "DelayMinimum", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { DelayMinimum = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse DelayMinimum with value {1}", DateTime.Now, value)); } eventDelayMinimum = true; } bool eventDelayMaximum = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "DelayMaximum", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { DelayMaximum = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse DelayMaximum with value {1}", DateTime.Now, value)); } eventDelayMaximum = true; } bool eventPresetCount = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "PresetCount", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { PresetCount = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse PresetCount with value {1}", DateTime.Now, value)); } eventPresetCount = true; } bool eventPresetIndex = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "PresetIndex", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { PresetIndex = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse PresetIndex with value {1}", DateTime.Now, value)); } eventPresetIndex = true; } if (eventDelay) { if (EventStateDelay != null) { try { EventStateDelay(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateDelay: " + ex); Assert.CheckDebug(false); } } } if (eventDelayMinimum) { if (EventStateDelayMinimum != null) { try { EventStateDelayMinimum(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateDelayMinimum: " + ex); Assert.CheckDebug(false); } } } if (eventDelayMaximum) { if (EventStateDelayMaximum != null) { try { EventStateDelayMaximum(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateDelayMaximum: " + ex); Assert.CheckDebug(false); } } } if (eventPresetCount) { if (EventStatePresetCount != null) { try { EventStatePresetCount(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStatePresetCount: " + ex); Assert.CheckDebug(false); } } } if (eventPresetIndex) { if (EventStatePresetIndex != null) { try { EventStatePresetIndex(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStatePresetIndex: " + ex); Assert.CheckDebug(false); } } } if (EventState != null) { EventState(this, EventArgs.Empty); } EventHandler <EventArgs> eventInitial = null; lock (iLock) { if (!iInitialEventReceived && e.SequenceNo == 0) { iInitialEventReceived = true; eventInitial = iEventInitial; } } if (eventInitial != null) { eventInitial(this, EventArgs.Empty); } }
protected override void EventServerEvent(EventServerUpnp obj, EventArgsEvent e) { if (e.SubscriptionId != SubscriptionId) { // This event is for a different subscription than the current. This can happen as follows: // // 1. Events A & B are received and queued up in the event server // 2. Event A is processed and is out of sequence - an unsubscribe/resubscribe is triggered // 3. By the time B is processed, the unsubscribe/resubscribe has completed and the SID is now different // // The upshot is that this event is ignored return; } lock (iLock) { if (e.SequenceNo != iExpectedSequenceNumber) { // An out of sequence event is being processed - log, resubscribe and discard UserLog.WriteLine("EventServerEvent(ServiceInfo): " + SubscriptionId + " Out of sequence event received. Expected " + iExpectedSequenceNumber + " got " + e.SequenceNo); // resubscribing means that the initial event will be resent iExpectedSequenceNumber = 0; Unsubscribe(); Subscribe(); return; } else { iExpectedSequenceNumber++; } } XmlNode variable; XmlNamespaceManager nsmanager = new XmlNamespaceManager(e.Xml.NameTable); nsmanager.AddNamespace("e", kNamespaceUpnpService); bool eventTrackCount = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "TrackCount", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { TrackCount = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse TrackCount with value {1}", DateTime.Now, value)); } eventTrackCount = true; } bool eventDetailsCount = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "DetailsCount", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { DetailsCount = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse DetailsCount with value {1}", DateTime.Now, value)); } eventDetailsCount = true; } bool eventMetatextCount = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "MetatextCount", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { MetatextCount = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse MetatextCount with value {1}", DateTime.Now, value)); } eventMetatextCount = true; } bool eventUri = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "Uri", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } Uri = value; eventUri = true; } bool eventMetadata = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "Metadata", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } Metadata = value; eventMetadata = true; } bool eventDuration = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "Duration", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { Duration = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse Duration with value {1}", DateTime.Now, value)); } eventDuration = true; } bool eventBitRate = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "BitRate", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { BitRate = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse BitRate with value {1}", DateTime.Now, value)); } eventBitRate = true; } bool eventBitDepth = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "BitDepth", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { BitDepth = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse BitDepth with value {1}", DateTime.Now, value)); } eventBitDepth = true; } bool eventSampleRate = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "SampleRate", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { SampleRate = uint.Parse(value); } catch (Exception) { UserLog.WriteLine(String.Format("{0}: Warning: Exception caught in parse SampleRate with value {1}", DateTime.Now, value)); } eventSampleRate = true; } bool eventLossless = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "Lossless", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } try { Lossless = bool.Parse(value); } catch (FormatException) { try { Lossless = (uint.Parse(value) > 0); } catch (FormatException) { Lossless = false; } } eventLossless = true; } bool eventCodecName = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "CodecName", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } CodecName = value; eventCodecName = true; } bool eventMetatext = false; variable = e.Xml.SelectSingleNode(kBasePropertyPath + "Metatext", nsmanager); if (variable != null) { string value = ""; XmlNode child = variable.FirstChild; if (child != null) { value = child.Value; } Metatext = value; eventMetatext = true; } if (eventTrackCount) { if (EventStateTrackCount != null) { try { EventStateTrackCount(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateTrackCount: " + ex); Assert.CheckDebug(false); } } } if (eventDetailsCount) { if (EventStateDetailsCount != null) { try { EventStateDetailsCount(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateDetailsCount: " + ex); Assert.CheckDebug(false); } } } if (eventMetatextCount) { if (EventStateMetatextCount != null) { try { EventStateMetatextCount(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateMetatextCount: " + ex); Assert.CheckDebug(false); } } } if (eventUri) { if (EventStateUri != null) { try { EventStateUri(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateUri: " + ex); Assert.CheckDebug(false); } } } if (eventMetadata) { if (EventStateMetadata != null) { try { EventStateMetadata(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateMetadata: " + ex); Assert.CheckDebug(false); } } } if (eventDuration) { if (EventStateDuration != null) { try { EventStateDuration(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateDuration: " + ex); Assert.CheckDebug(false); } } } if (eventBitRate) { if (EventStateBitRate != null) { try { EventStateBitRate(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateBitRate: " + ex); Assert.CheckDebug(false); } } } if (eventBitDepth) { if (EventStateBitDepth != null) { try { EventStateBitDepth(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateBitDepth: " + ex); Assert.CheckDebug(false); } } } if (eventSampleRate) { if (EventStateSampleRate != null) { try { EventStateSampleRate(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateSampleRate: " + ex); Assert.CheckDebug(false); } } } if (eventLossless) { if (EventStateLossless != null) { try { EventStateLossless(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateLossless: " + ex); Assert.CheckDebug(false); } } } if (eventCodecName) { if (EventStateCodecName != null) { try { EventStateCodecName(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateCodecName: " + ex); Assert.CheckDebug(false); } } } if (eventMetatext) { if (EventStateMetatext != null) { try { EventStateMetatext(this, EventArgs.Empty); } catch (Exception ex) { UserLog.WriteLine("Exception caught in EventStateMetatext: " + ex); Assert.CheckDebug(false); } } } if (EventState != null) { EventState(this, EventArgs.Empty); } EventHandler <EventArgs> eventInitial = null; lock (iLock) { if (!iInitialEventReceived && e.SequenceNo == 0) { iInitialEventReceived = true; eventInitial = iEventInitial; } } if (eventInitial != null) { eventInitial(this, EventArgs.Empty); } }