Esempio n. 1
0
            protected override object SetUpMember(int index, object member)
            {
                InstructorAdvertisement ia = member as InstructorAdvertisement;

                if (ia.Multicast)
                {
#if RTP_BUILD
                    RTPClassroomManager mgr;
                    if (m_Parent.m_RTPAdvertisedClassrooms.ContainsKey(ia))
                    {
                        mgr = (RTPClassroomManager)m_Parent.m_RTPAdvertisedClassrooms[ia];
                    }
                    else
                    {
                        mgr = new RTPClassroomManager(m_Parent.m_Model, m_Parent.m_RTPConnectionMgr, ia.HumanName, ia.Endpoint, true);
                        m_Parent.m_RTPAdvertisedClassrooms.Add(ia, mgr);
                    }
                    //put it in the model so the UI will see it.
                    using (Synchronizer.Lock(this.m_Parent.m_RTPConnectionMgr.Protocol.SyncRoot)) {
                        this.m_Parent.m_RTPConnectionMgr.Protocol.Classrooms.Add(mgr.Classroom);
                    }
                    //Set it as the return value to cause it to be supplied as the tag in teardown.
                    return(mgr);
#else
                    return(null);
#endif
                }
                else
                {
                    TCPClientClassroomManager mgr;
                    //If we don't already have a TCPClientClassroomManager for this endpoint, create one.
                    if (m_Parent.m_TCPClientClassrooms.ContainsKey(ia))
                    {
                        mgr = (TCPClientClassroomManager)m_Parent.m_TCPClientClassrooms[ia];
                    }
                    else
                    {
                        mgr = new TCPClientClassroomManager(m_Parent.m_Model, m_Parent.m_TCPConnectionMgr, ia);
                        m_Parent.m_TCPClientClassrooms.Add(ia, mgr);
                    }
                    //put it in the model so the UI will see it.
                    using (Synchronizer.Lock(this.m_Parent.m_TCPConnectionMgr.Protocol.SyncRoot)) {
                        this.m_Parent.m_TCPConnectionMgr.Protocol.Classrooms.Add(mgr.Classroom);
                    }
                    //Set it as the return value to cause it to be supplied as the tag in teardown.
                    return(mgr);
                }
            }
Esempio n. 2
0
            protected override void TearDownMember(int index, object member, object tag)
            {
                //Remove a ClassroomModel so that it will not appear in the UI.
                //Note that we don't dispose the *ClassroomManager here because we don't want it to disconnect.
                TCPClientClassroomManager mgr = tag as TCPClientClassroomManager;

                if (mgr != null)
                {
                    using (Synchronizer.Lock(this.m_Parent.m_TCPConnectionMgr.Protocol.SyncRoot)) {
                        this.m_Parent.m_TCPConnectionMgr.Protocol.Classrooms.Remove(mgr.Classroom);
                    }
                }
#if RTP_BUILD
                RTPClassroomManager rtpMgr = tag as RTPClassroomManager;
                if (rtpMgr != null)
                {
                    using (Synchronizer.Lock(this.m_Parent.m_RTPConnectionMgr.Protocol.SyncRoot)) {
                        this.m_Parent.m_RTPConnectionMgr.Protocol.Classrooms.Remove(rtpMgr.Classroom);
                    }
                }
#endif
            }