private void SendVersionResponse(VersionExchange ve, VersionResponseMessage vrm)
 {
     vrm.Group = new SingletonGroup(ve.RemoteParticipant);
     vrm.Tags  = new MessageTags();
     vrm.Tags.BridgePriority = MessagePriority.Lowest;
     m_Service.m_Sender.Send(vrm);
     Trace.WriteLine("Sent VersionResponseMessage to Participant ID: " + ve.RemoteParticipant.Guid.ToString());
 }
            //Send a VersionResponesMessage
            private void SendVersionResponseHandler(object sender, PropertyEventArgs args)
            {
                VersionExchange         ve   = (VersionExchange)sender;
                PropertyChangeEventArgs pcea = (PropertyChangeEventArgs)args;

                if (pcea.NewValue != null)
                {
                    VersionResponseMessage vrm = (VersionResponseMessage)(pcea.NewValue);
                    SendVersionResponse(ve, vrm);
                }
            }
        /// <summary>
        /// Generate the outbound VersionResponseMessage
        /// </summary>
        /// <param name="localVersion"></param>
        /// <param name="remoteVersion"></param>
        /// <returns></returns>
        public static VersionResponseMessage GetVersionResponseMessage(Version remoteVersion)
        {
            VersionResponseMessage vrm = new VersionResponseMessage();

            ///If the remote version is newer, we always send the default message which claims full compatibility.
            ///If this is not the case, the remote node's compatibility matrix will be used to override the properties.
            ///If the remote node's version is older, the information we provide here will be meaningful.

            if (remoteVersion < VersionExchangeModel.LocalVersion) {
                /// Note: When new CP3 versions are created, add code here to populate the
                /// VersionResponseMessage properties with compatibility warnings and actions as appropriate.
                /// Note that the pop-up and dialog always show the compatibility info URL, so do not include it
                /// in the warning message.

                ///This is only displayed in the Version Compatibility Info dialog:
                //vrm.Compatibility = VersionCompatibility.Partial;

                ///IssueWarning means that a pop-up appears on student or public nodes with earlier version when connection is made.
                //vrm.Action = VersionIncompatibilityRecommendedAction.IssueWarning;

                ///The WarningMessage is displayed on the remote node with earlier version.  It appears in the pop-up if
                /// the remote node is public or student, and it appears in the Compatiblity Info dialog available from the
                /// menu for all roles.
                //vrm.WarningMessage = "The local Classroom Presenter version has known compatibility problems affecting feature X when connected to this remote node. Upgrade of the local Classroom Presenter is recommended.";

                ///The LocalWarningMessage is not part of the serialized message. It is only displayed locally in the
                /// Compatibility Info dialog on the node with the later version.
                //vrm.LocalWarningMessage = "The remote node has known problems with feature X. Upgrade of the remote node is recommended.";

                #region QuickPoll
                Version qpVersion = new Version(3, 0, 1654);
                if (remoteVersion < qpVersion) {
                    vrm.Compatibility = VersionCompatibility.Partial;
                    vrm.Action = VersionIncompatibilityRecommendedAction.NoAction;
                    vrm.WarningMessage = Strings.QuickPollVersionWarning;
                    vrm.LocalWarningMessage = Strings.QuickPollLocalVersionWarning;
                }
                #endregion QuickPoll
            }

            return vrm;
        }
        /// <summary>
        /// Called when a VersionResponseMessage is received
        /// </summary>
        /// <param name="participantModel"></param>
        /// <param name="versionResponseMessage"></param>
        internal void ReceiveVersionResponse(ParticipantModel remoteParticipant, VersionResponseMessage versionResponseMessage)
        {
            Trace.WriteLine("VersionExchangeModel.ReceiveVersionResponse started. remoteParticipant=" +
                remoteParticipant.Guid.ToString() + ";responderID=" + versionResponseMessage.ResponderId.ToString());

            VersionExchange ve = null;
            //Look up the VersionExchange for this remote participant
            using (Synchronizer.Lock(this.SyncRoot)) {
                if (m_VersionExchangeDictionary.ContainsKey(versionResponseMessage.ResponderId)) {
                    ve = m_VersionExchangeDictionary[versionResponseMessage.ResponderId];
                }
            }
            //Let the VersionExchange handle the inbound message.
            if (ve != null) {
                ve.ReceiveResponse(versionResponseMessage);
            }
            else {
                Trace.WriteLine("Warning: Failed to find a pending version exchange to match inbound response message from participant: " + remoteParticipant.Guid.ToString());
            }
        }
        /// <summary>
        /// Handle inbound VersionResponseMessage.  
        /// </summary>
        /// <param name="responseMessage"></param>
        public void ReceiveResponse(VersionResponseMessage responseMessage)
        {
            Trace.WriteLine("VersionResponseMessage received from " + m_RemoteParticipant.Guid.ToString());
            m_RemoteVersion = responseMessage.ResponderVersion;

            if (m_RemoteVersion > VersionExchangeModel.LocalVersion) {
                m_RemoteCompatibility = responseMessage.Compatibility;
                m_RecommendedAction = responseMessage.Action;
                m_WarningMessage = responseMessage.WarningMessage;
                if (!this.m_LocalNodeIsInstructor) {
                    if ((m_RecommendedAction == VersionIncompatibilityRecommendedAction.IssueWarning) &&
                        (m_WarningMessage != null) && (m_WarningMessage != "")) {
                        //Cause a local pop-up warning to be displayed.
                        PresenterModel.TheInstance.VersionExchange.SetPopUpWarning(m_WarningMessage);
                    }
                }
                else {
                    //Here we might want to show warning, but aggregate across all participants and show one messagebox.
                }
            }
            else if (m_RemoteVersion < VersionExchangeModel.LocalVersion) {
                //This node is newer than the remote node, so use the local compatibility matrix
                // to generate compatibility information.
                VersionResponseMessage vrm = CompatiblityMatrix.GetVersionResponseMessage(m_RemoteVersion);
                m_RemoteCompatibility = vrm.Compatibility;
                m_RecommendedAction = vrm.Action;
                m_WarningMessage = vrm.LocalWarningMessage;

                //If the local node is an instructor and if the local node has a later version, we send one more
                // response back to the client since our verison of the compatibility matrix may have information
                // that the client's matrix doesn't have.
                if (this.m_LocalNodeIsInstructor) {
                    using (Synchronizer.Lock(this.SyncRoot)) {
                        this.SetPublishedProperty("SendVersionResponse", ref this.m_SendVersionResponse, vrm);
                    }
                }

                //Are there any cases where we want to raise events?  If so, the code can be added later as needed.
            }
            else {
                //Versions are equal.  We fully expect compatiblity in this case.
                m_RemoteCompatibility = responseMessage.Compatibility;
                m_RecommendedAction = responseMessage.Action;
                m_WarningMessage = responseMessage.WarningMessage;
            }
        }
 private void SendVersionResponse(VersionExchange ve, VersionResponseMessage vrm)
 {
     vrm.Group = new SingletonGroup(ve.RemoteParticipant);
     vrm.Tags = new MessageTags();
     vrm.Tags.BridgePriority = MessagePriority.Lowest;
     m_Service.m_Sender.Send(vrm);
     Trace.WriteLine("Sent VersionResponseMessage to Participant ID: " + ve.RemoteParticipant.Guid.ToString());
 }