コード例 #1
0
 public TCPClientClassroomManager(PresenterModel model, TCPConnectionManager connection, 
     InstructorAdvertisement instructorAdvertisement)
 {
     this.m_InstructorAdvertisement = instructorAdvertisement;
     this.m_Model = model;
     this.m_ClientConnected = false;
     this.m_Classroom = new ClassroomModel(connection.Protocol, m_InstructorAdvertisement.HumanName, ClassroomModelType.Dynamic);
     this.m_Classroom.Changing["Connected"].Add(new PropertyEventHandler(this.HandleConnectedChanging));
 }
コード例 #2
0
ファイル: BroadcastManager.cs プロジェクト: zhujingcheng/CP3
            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);
                }
            }
コード例 #3
0
 public void Remove(InstructorAdvertisement value)
 {
     List.Remove(value);
 }
コード例 #4
0
 public void Insert(int index, InstructorAdvertisement value)
 {
     List.Insert(index, value);
 }
コード例 #5
0
 public int IndexOf(InstructorAdvertisement value)
 {
     return List.IndexOf(value);
 }
コード例 #6
0
 public bool Contains(InstructorAdvertisement value)
 {
     return List.Contains(value);
 }
コード例 #7
0
 public int Add(InstructorAdvertisement value)
 {
     return List.Add(value);
 }
コード例 #8
0
        /// <summary>
        /// Handle one inbound BroadcastMessage
        /// </summary>
        /// <param name="message"></param>
        /// <param name="timestamp"></param>
        private void processMessage(BroadcastMessage message, DateTime timestamp)
        {
            //List<InstructorAdvertisement> nonLocalPublicSubnets = new List<InstructorAdvertisement>();
            foreach (IPEndPoint ep in message.EndPoints) {
                InstructorAdvertisement ia = new InstructorAdvertisement(ep, message.HumanName, message.PresentationName, message.SenderID, message.ShowIP);
                using(Synchronizer.Lock(this.SyncRoot)) {
                    if (m_InstructorAdvertisements.Contains(ia)) {  //We already have the entry, just update the timestamp.
                        int index = m_InstructorAdvertisements.IndexOf(ia);
                        m_InstructorAdvertisements[index].Timestamp = DateTime.Now;
                        continue;
                    }

                    if (ep.AddressFamily.Equals(AddressFamily.InterNetwork)) { //IPv4
                        if (!isPrivateSubnet(ep.Address)) {
                            //If there are both local and non-local public subnets, keep only the local ones (plus multicast)
                            if (matchesAnyLocalSubnet(ep.Address)) {
                                Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                                m_InstructorAdvertisements.Add(ia); //Not a private subnet, add to the table.
                            }
                            else if (isMulticastAddress(ep.Address)) {
                                Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                                ia.Multicast = true;
                                m_InstructorAdvertisements.Add(ia); //Not a private subnet, add to the table.
                            }
                            else {
                                //nonLocalPublicSubnets.Add(ia);
                            }
                        }
                        else {
                            //If it is a private subnet, the listener also needs to be on that subnet
                            //In effect, we can't talk to NAT'ed hosts directly unless we are also on the same NAT'ed network.
                            //Otherwise, we would have to connect to a port forwarding router.
                            if (matchesAnyLocalSubnet(ep.Address)) {
                                Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                                m_InstructorAdvertisements.Add(ia);
                            }
                        }
                    }
                    else if (ep.AddressFamily.Equals(AddressFamily.InterNetworkV6)) {
                        if (BroadcastManager.UseIPv6) {
                            //Don't show any IPv6 entries unless IPv6 is enabled on the local system.
                            //TODO: To correctly handle link local and site local, we need to do a bit more work here.
                            Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                            m_InstructorAdvertisements.Add(ia);
                        }
                    }
                }
            }

            //Are there cases were we would want to show the non-local public subnet addresses?
        }
コード例 #9
0
        /// <summary>
        /// Treat all instances with the same endpoint as equal
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            InstructorAdvertisement ie = obj as InstructorAdvertisement;

            return(Endpoint.Equals(ie.Endpoint));
        }
コード例 #10
0
 public bool Contains(InstructorAdvertisement value)
 {
     return(List.Contains(value));
 }
コード例 #11
0
 public void Remove(InstructorAdvertisement value)
 {
     List.Remove(value);
 }
コード例 #12
0
 public void Insert(int index, InstructorAdvertisement value)
 {
     List.Insert(index, value);
 }
コード例 #13
0
 public int IndexOf(InstructorAdvertisement value)
 {
     return(List.IndexOf(value));
 }
コード例 #14
0
 public int Add(InstructorAdvertisement value)
 {
     return(List.Add(value));
 }
コード例 #15
0
        /// <summary>
        /// Handle one inbound BroadcastMessage
        /// </summary>
        /// <param name="message"></param>
        /// <param name="timestamp"></param>
        private void processMessage(BroadcastMessage message, DateTime timestamp)
        {
            //List<InstructorAdvertisement> nonLocalPublicSubnets = new List<InstructorAdvertisement>();
            foreach (IPEndPoint ep in message.EndPoints)
            {
                InstructorAdvertisement ia = new InstructorAdvertisement(ep, message.HumanName, message.PresentationName, message.SenderID, message.ShowIP);
                using (Synchronizer.Lock(this.SyncRoot)) {
                    if (m_InstructorAdvertisements.Contains(ia))    //We already have the entry, just update the timestamp.
                    {
                        int index = m_InstructorAdvertisements.IndexOf(ia);
                        m_InstructorAdvertisements[index].Timestamp = DateTime.Now;
                        continue;
                    }

                    if (ep.AddressFamily.Equals(AddressFamily.InterNetwork))   //IPv4
                    {
                        if (!isPrivateSubnet(ep.Address))
                        {
                            //If there are both local and non-local public subnets, keep only the local ones (plus multicast)
                            if (matchesAnyLocalSubnet(ep.Address))
                            {
                                Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                                m_InstructorAdvertisements.Add(ia); //Not a private subnet, add to the table.
                            }
                            else if (isMulticastAddress(ep.Address))
                            {
                                Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                                ia.Multicast = true;
                                m_InstructorAdvertisements.Add(ia); //Not a private subnet, add to the table.
                            }
                            else
                            {
                                //nonLocalPublicSubnets.Add(ia);
                            }
                        }
                        else
                        {
                            //If it is a private subnet, the listener also needs to be on that subnet
                            //In effect, we can't talk to NAT'ed hosts directly unless we are also on the same NAT'ed network.
                            //Otherwise, we would have to connect to a port forwarding router.
                            if (matchesAnyLocalSubnet(ep.Address))
                            {
                                Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                                m_InstructorAdvertisements.Add(ia);
                            }
                        }
                    }
                    else if (ep.AddressFamily.Equals(AddressFamily.InterNetworkV6))
                    {
                        if (BroadcastManager.UseIPv6)
                        {
                            //Don't show any IPv6 entries unless IPv6 is enabled on the local system.
                            //TODO: To correctly handle link local and site local, we need to do a bit more work here.
                            Trace.WriteLine("Adding Instructor Table Entry: " + ia.ToString(), this.GetType().ToString());
                            m_InstructorAdvertisements.Add(ia);
                        }
                    }
                }
            }

            //Are there cases were we would want to show the non-local public subnet addresses?
        }