/// <summary> /// The response that usually from the peers that received prior the SynchronizationRequest /// </summary> /// <param name="response">the response from the peers to the requester peer</param> void ISynchronizedState.SynchronizationKeysResponse(SynchronizationResponseContainer response) { if (response.IsOwnMessage) { return; } //first message win , other messages ignore pattern if (synchronizationMode == SynchronizationMode.Economical && alreadySynchronizationDetailedRequest) { LogManager.GetCurrentClassLogger().Debug("synchronization stopped -> synchronizationMode == SynchronizationMode.Economical && alreadySynchronizationDetailedRequest - its legal , but for debugging information for the implementer should consider if this is the correct behavior"); return; } alreadySynchronizationDetailedRequest = true; Task <BusinessLogicMessageBase> .Factory.StartNew(() => businessLogic.ProvideSynchronizationDetailRequest(response.Response)).ContinueWith(task => { //exception handling if (task.IsFaulted) { task.Exception.Handle(exception => { LogManager.Fatal(exception); return(true); }); return; } if (task.Result == null) { LogManager.GetCurrentClassLogger().Debug("businessLogic.ProvideSynchronizationDetailRequest() return null - SynchronizationDetailsRequest will not sent to neighbors peers - its legal , but for debugging information for the implementer should consider if this is the correct behavior"); return; } var detailRequest = new SynchronizationDetailsRequestContainer { Request = task.Result }; //send the request back to the mesh Proxy.SynchronizationDetailsRequest(detailRequest); }); }
/// <summary> /// The first request usually from the peer that joined to the mesh /// that ask for synchronization /// </summary> /// <param name="request">the request from the peer to his neighbors</param> void ISynchronizedState.SynchronizationRequest(SynchronizationRequest request) { if (request.IsOwnMessage) { return; } if (request.FullDetailedResponse) { Task <BusinessLogicMessageBase> .Factory.StartNew(() => businessLogic.ProvideFullSynchronizationDetailResponse()).ContinueWith(task => { //exception handling if (task.IsFaulted) { task.Exception.Handle(exception => { LogManager.Fatal(exception); return(true); }); return; } if (task.Result == null) { LogManager.GetCurrentClassLogger().Debug("businessLogic.ProvideFullSynchronizationDetailResponse() return null - SynchronizationDetailsResponse will not sent to neighbors peers - its legal , but for debugging information for the implementer should consider if this is the correct behavior"); return; } var response = new SynchronizationDetailsResponseContainer { Response = task.Result }; //send the response Proxy.SynchronizationDetailsResponse(response); }); } else { Task <BusinessLogicMessageBase> .Factory.StartNew(() => businessLogic.ProvideSynchronizationResponse(request)).ContinueWith(task => { //exception handling if (task.IsFaulted) { task.Exception.Handle(exception => { LogManager.Fatal(exception); return(true); }); return; } if (task.Result == null) { LogManager.GetCurrentClassLogger().Debug("businessLogic.ProvideSynchronizationResponse() return null - SynchronizationKeysResponse will not sent to neighbors peers - its legal , but for debugging information for the implementer should consider if this is the correct behavior"); return; } //send the response var response = new SynchronizationResponseContainer { Response = task.Result }; Proxy.SynchronizationKeysResponse(response); }); } }
/// <summary> /// The response that usually from the peers that received prior the SynchronizationRequest /// </summary> /// <param name="response">the response from the peers to the requester peer</param> void ISynchronizedState.SynchronizationKeysResponse(SynchronizationResponseContainer response) { Contract.Requires <ArgumentNullException>(response != null); }