//New VersionExchange added to the collection: protected override object SetUpMember(int index, object member) { VersionExchange ve = (VersionExchange)member; //Set up an event handler to send outbound responses in all cases: using (Synchronizer.Lock(ve.SyncRoot)) { ve.Changed["SendVersionResponse"].Add(new PropertyEventHandler(SendVersionResponseHandler)); if (ve.SendVersionResponse != null) { Trace.WriteLine("VersionExchangeCollection.SetUpMember: VersionResponseMessage already set before event handler added: Sending response now."); SendVersionResponse(ve, ve.SendVersionResponse); } } //Send a request only if the VersionExchange is configured for it; Instructor nodes initiate the exchange. if (ve.SendRequest) { VersionRequestMessage vrm = new VersionRequestMessage(); vrm.Group = new SingletonGroup(ve.RemoteParticipant); vrm.Tags = new MessageTags(); vrm.Tags.BridgePriority = MessagePriority.Lowest; m_Service.m_Sender.Send(vrm); Trace.WriteLine("Sent VersionRequestMessage to Participant ID: " + ve.RemoteParticipant.Guid.ToString()); } return(null); //No tag needed }
/// <summary> /// Called when a VersionRequestMessage is received /// </summary> /// <param name="remoteParticipant"></param> /// <param name="version"></param> public void ReceiveVersionRequest(ParticipantModel remoteParticipant, VersionRequestMessage requestMessage) { Trace.WriteLine("VersionExchangeModel.ReceiveVersionRequest started. remoteParticipant=" + remoteParticipant.Guid.ToString() + "; requesterID= " + requestMessage.RequesterId.ToString()); VersionExchange ve; //Make a VersionExchange object if needed. using (Synchronizer.Lock(this.SyncRoot)) { if (m_VersionExchangeDictionary.ContainsKey(remoteParticipant.Guid)) { ve = m_VersionExchangeDictionary[remoteParticipant.Guid]; } else { //This probably should not happen, but if it does we are covered. ve = new VersionExchange(remoteParticipant); m_VersionExchangeDictionary.Add(remoteParticipant.Guid, ve); m_VersionExchanges.Add(ve); Trace.WriteLine("Created a VersionExchange in response to Version Request from participant: " + remoteParticipant.Guid.ToString()); } } //Let the VersionExchange object process the inbound message ve.ReceiveRequest(requestMessage.RequesterVersion); }
//New VersionExchange added to the collection: protected override object SetUpMember(int index, object member) { VersionExchange ve = (VersionExchange)member; //Set up an event handler to send outbound responses in all cases: using (Synchronizer.Lock(ve.SyncRoot)) { ve.Changed["SendVersionResponse"].Add(new PropertyEventHandler(SendVersionResponseHandler)); if (ve.SendVersionResponse != null) { Trace.WriteLine("VersionExchangeCollection.SetUpMember: VersionResponseMessage already set before event handler added: Sending response now."); SendVersionResponse(ve, ve.SendVersionResponse); } } //Send a request only if the VersionExchange is configured for it; Instructor nodes initiate the exchange. if (ve.SendRequest) { VersionRequestMessage vrm = new VersionRequestMessage(); vrm.Group = new SingletonGroup(ve.RemoteParticipant); vrm.Tags = new MessageTags(); vrm.Tags.BridgePriority = MessagePriority.Lowest; m_Service.m_Sender.Send(vrm); Trace.WriteLine("Sent VersionRequestMessage to Participant ID: " + ve.RemoteParticipant.Guid.ToString()); } return null; //No tag needed }