Exemplo n.º 1
0
        public BroadcastManager(PresenterModel model, TCPConnectionManager tcpMgr)
        {
            IPv6LinkLocalMulticast = IPAddress.Parse("ff02::1");
            UseIPv6 = false;
            //Use IPv6 only if IPv4 is unavailable

            if ((!Socket.OSSupportsIPv4) && (Socket.OSSupportsIPv6))
            {
                UseIPv6 = true;
            }
            this.m_Model                   = model;
            this.m_TCPConnectionMgr        = tcpMgr;
            this.m_TCPClassroomMgr         = tcpMgr.ClassroomManager;
            this.m_TCPClientClassrooms     = new Hashtable();
            this.m_RTPAdvertisedClassrooms = new Hashtable();
            m_EventQueue                   = new ThreadEventQueue();
            // this.m_RTPConnectionMgr = rtpMgr;

            StartListener();

            //Subscribe to the instructor advertisements that the BroadcastListener provides
            m_InstructorAdvertisementCollectionHelper = new InstructorAdvertisementCollectionHelper(this, this.m_Listener);

            //Subscribe to all the RTP Classrooms to learn when they connect/disconnect.
            //Notice that we assume there will be no new RTP classrooms created (other than the ones we create in response to advertisements).

            /*this.m_RtpClassroomConnected = false;
             * using (Synchronizer.Lock(m_RTPConnectionMgr.Protocol.SyncRoot)) {
             *  foreach (ClassroomModel cm in m_RTPConnectionMgr.Protocol.Classrooms) {
             *      cm.Changed["Connected"].Add(new PropertyEventHandler(OnRtpClassroomConnectedChanged));
             *  }
             * }*/

            m_IsInstructor = false;
            using (Synchronizer.Lock(this.m_Model.Participant.SyncRoot)) {
                //This is the server's identifier which remains constant for the app instance
                m_SenderID = this.m_Model.Participant.Guid;
                //Subscribe to the local presenter's role to track when we are instructor
                this.m_Model.Participant.Changed["Role"].Add(new PropertyEventHandler(OnRoleChanged));
                if (this.m_Model.Participant.Role is InstructorModel)
                {
                    m_IsInstructor = true;
                }
            }

            //Subscribe to the TCP Server to find out when it starts and stops
            this.m_TCPClassroomMgr.Changed["ServerStarted"].Add(new PropertyEventHandler(ServerStartedChangedHandler));
            m_TcpServerStarted = false;
            using (Synchronizer.Lock(m_TCPClassroomMgr.SyncRoot)) {
                if (m_TCPClassroomMgr.ServerStarted)
                {
                    m_TcpServerStarted = true;
                }
            }

            UpdateSenderStatus();
        }
Exemplo n.º 2
0
        public BroadcastManager(PresenterModel model, TCPConnectionManager tcpMgr)
        {
            IPv6LinkLocalMulticast = IPAddress.Parse("ff02::1");
            UseIPv6 = false;
            //Use IPv6 only if IPv4 is unavailable

            if ((!Socket.OSSupportsIPv4) && (Socket.OSSupportsIPv6)) {
                UseIPv6 = true;
            }
            this.m_Model = model;
            this.m_TCPConnectionMgr = tcpMgr;
            this.m_TCPClassroomMgr = tcpMgr.ClassroomManager;
            this.m_TCPClientClassrooms = new Hashtable();
            this.m_RTPAdvertisedClassrooms = new Hashtable();
            m_EventQueue = new ThreadEventQueue();
               // this.m_RTPConnectionMgr = rtpMgr;

            StartListener();

            //Subscribe to the instructor advertisements that the BroadcastListener provides
            m_InstructorAdvertisementCollectionHelper = new InstructorAdvertisementCollectionHelper(this, this.m_Listener);

            //Subscribe to all the RTP Classrooms to learn when they connect/disconnect.
            //Notice that we assume there will be no new RTP classrooms created (other than the ones we create in response to advertisements).
            /*this.m_RtpClassroomConnected = false;
            using (Synchronizer.Lock(m_RTPConnectionMgr.Protocol.SyncRoot)) {
                foreach (ClassroomModel cm in m_RTPConnectionMgr.Protocol.Classrooms) {
                    cm.Changed["Connected"].Add(new PropertyEventHandler(OnRtpClassroomConnectedChanged));
                }
            }*/

            m_IsInstructor = false;
            using (Synchronizer.Lock(this.m_Model.Participant.SyncRoot)) {
                //This is the server's identifier which remains constant for the app instance
                m_SenderID = this.m_Model.Participant.Guid;
                //Subscribe to the local presenter's role to track when we are instructor
                this.m_Model.Participant.Changed["Role"].Add(new PropertyEventHandler(OnRoleChanged));
                if (this.m_Model.Participant.Role is InstructorModel) {
                    m_IsInstructor = true;
                }
            }

            //Subscribe to the TCP Server to find out when it starts and stops
            this.m_TCPClassroomMgr.Changed["ServerStarted"].Add(new PropertyEventHandler(ServerStartedChangedHandler));
            m_TcpServerStarted = false;
            using (Synchronizer.Lock(m_TCPClassroomMgr.SyncRoot)) {
                if (m_TCPClassroomMgr.ServerStarted) {
                    m_TcpServerStarted = true;
                }
            }

            UpdateSenderStatus();
        }