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(); }
protected override object SetUpMember(int index, object member) { ProtocolModel protocol = member as ProtocolModel; if (protocol == null) { return(null); } TCPConnectionManager connection = protocol.ConnectionManager as TCPConnectionManager; if (connection == null) { return(null); } this.m_Parent.AddClassroom(connection.ClassroomManager); return(connection.ClassroomManager); }
public static void ViewerThreadStart(List <string> inputFiles, bool standalone) { Trace.WriteLine("ViewerThreadStart starting"); Application.EnableVisualStyles(); Application.DoEvents(); Process p = Process.GetCurrentProcess(); SetProcessWorkingSetSize(p.Handle, -1, -1); #if WEBSERVER // Create the web service Web.WebService web_server = new Web.WebService(null, "9090"); #endif #if DEBUG && LOGGING LoggingService logger = new LoggingService(); #endif Trace.WriteLine("Make PresenterModel"); PresenterModel model = new PresenterModel(); Trace.WriteLine("Make DeckMarshalService"); using (DeckMarshalService loader = new DefaultDeckMarshalService()) { Trace.WriteLine("Construct ViewerForm"); ViewerForm viewer = new ViewerForm(loader, model); ConnectionManager rtp = null; #if RTP_BUILD Trace.WriteLine("Make RTPConnectionManager"); rtp = new RTPConnectionManager(model); #endif ConnectionManager tcp = new TCPConnectionManager(model); #if RTP_BUILD Trace.WriteLine("Make BroadcastManager"); BroadcastManager bm = new BroadcastManager(model, (TCPConnectionManager)tcp, (RTPConnectionManager)rtp); #else BroadcastManager bm = new BroadcastManager(model, (TCPConnectionManager)tcp); #endif using (rtp) { using (tcp) { using (bm) { Trace.WriteLine("Make ViewerStateService"); using (ViewerStateService viewerState = new ViewerStateService(model.ViewerState)) { using (RegistryService registry = new RegistryService(model.ViewerState)) { using (RegistryService penreg = new RegistryService(model.PenState)) { #if DEBUG && LOGGING // Attach the logger to the model logger.AttachToModel(model.ViewerState); #endif #if STUDENT_CLIENT_ONLY using (Synchronizer.Lock(model.ViewerState.SyncRoot)){ model.ViewerState.iRole = 1; } #endif // Start the printing service PrintingService printing = new PrintingService(model.ViewerState); using (WorkspaceUndoService undo = new WorkspaceUndoService(viewer.m_EventQueue, model)) { using (Synchronizer.Lock(model.Network.SyncRoot)) { model.Network.Protocols.Add(tcp.Protocol); #if RTP_BUILD model.Network.Protocols.Add(rtp.Protocol); #endif } using (NetworkAssociationService association = new NetworkAssociationService(viewer.m_EventQueue, model)) { using (DeckMatcherService deckMatcher = new DeckMatcherService(viewer.m_EventQueue, model)) { // Set the Initial Deck to Load if we are Loading from an Icon viewer.OpenInputFiles = inputFiles; viewer.StandAlone = standalone; Trace.WriteLine("Ready to run viewer"); Application.Run(viewer); } } } penreg.SaveAllProperties(); } registry.SaveAllProperties(); } } } } } } #if WEBSERVER // Dispose of the web server web_server.Dispose(); #endif }