/// <summary> /// This constructor is called with the UPnPDevice that contains the services of a MediaRenderer device. /// </summary> /// <param name="device">The UPnPDevice</param> public AVRenderer(UPnPDevice device) { OpenSource.Utilities.InstanceTracker.Add(this); this.ConnectionMonitor.OnExpired += new LifeTimeMonitor.LifeTimeHandler(ConnectionMonitorSink); MainDevice = device; ConnectionManager = new CpConnectionManager(device.GetServices(CpConnectionManager.SERVICE_NAME)[0]); ConnectionManager.OnStateVariable_CurrentConnectionIDs += new CpConnectionManager.StateVariableModifiedHandler_CurrentConnectionIDs(ConnectionIDEventSink); ConnectionManager._subscribe(90); //TODO: Fails to compile after using generated code from DeviceBuilderV23. Seems like CpConnectionManager.PeriodicRenewFailedHandler is no longer defined? //ConnectionManager.OnPeriodicRenewFailed += new CpConnectionManager.PeriodicRenewFailedHandler(PeriodicRenewFailedSink); // Grab initial state of the ConnectionManager Service if (ConnectionManager.HasAction_GetProtocolInfo) { ConnectionManager.GetProtocolInfo(null, new CpConnectionManager.Delegate_OnResult_GetProtocolInfo(GetProtocolInfoSink)); } if (ConnectionManager.HasAction_GetCurrentConnectionIDs) { ConnectionManager.GetCurrentConnectionIDs(null, new CpConnectionManager.Delegate_OnResult_GetCurrentConnectionIDs(IDSink)); } if (ConnectionManager.HasAction_PrepareForConnection == false) { lock (InstanceList) { AVConnection ac = new AVConnection(MainDevice, 0, 0, 0, new AVConnection.OnReadyHandler(ReadySink), null); ac._Parent = this; DontEverDelete = true; if (InstanceList.Count == 0) { InstanceList.Add(ac); } } /* Wait for Ready * if(InstanceList.Count>0) * { * if(OnCreateConnection!=null) OnCreateConnection(this,(AVConnection)InstanceList[0],Guid.NewGuid().GetHashCode()); * } */ } }
private bool ConnectionManagerEventsTest() { string ConnectionIDs = ""; StartCountDown(30, 90); CM.Sync_GetCurrentConnectionIDs(out ConnectionIDs); AbortCountDown(); CM.OnStateVariable_CurrentConnectionIDs += new CpConnectionManager.StateVariableModifiedHandler_CurrentConnectionIDs(CurrentConnectionIDSink); CM._subscribe(250); StartCountDown(60, 90); bool OK = true; if (Ev.WaitOne(30000, false)) { if (CM.CurrentConnectionIDs != ConnectionIDs) { AddEvent(LogImportance.Critical, "Connection Handling", " Inconsistent ConnectionID"); AddEvent(LogImportance.Remark, "Connection Handling", " GetCurrentConnectionIDs[" + ConnectionIDs + "] Event[" + CM.CurrentConnectionIDs + "]"); OK = false; } } else { AddEvent(LogImportance.Critical, "Connection Handling", " Did not receive events for CurrentConnectionIDs"); OK = false; } if (OK) { AddEvent(LogImportance.Remark, "Connection Handling", " Correctly received CurrentConnectionIDs events"); } CM.OnStateVariable_CurrentConnectionIDs -= new CpConnectionManager.StateVariableModifiedHandler_CurrentConnectionIDs(CurrentConnectionIDSink); AbortCountDown(); return(OK); }