Ejemplo n.º 1
0
        /// <summary>
        /// The response the peer that received prior the SynchronizationDetailsRequest
        /// </summary>
        /// <param name="response">the response from the peer</param>
        void ISynchronizedState.SynchronizationDetailsResponse(SynchronizationDetailsResponseContainer response)
        {
            if (synchronizationMode == SynchronizationMode.Economical && alreadySynchronizationDetailsResponse)
            {
                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;
            }
            alreadySynchronizationDetailsResponse = true;

            try
            {
                businessLogic.IsNeedFullSynchronization = false;
                businessLogic.OnSynchronizationDetailsResponseReceived(response.Response);
            }
            catch (Exception exception)
            {
                HelperMethods.HandleBusinessLogicException(exception);
            }
            finally
            {
                OnSynchronizationComplete();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The second request that usually from the peer that received prior the SynchronizationResponse
        /// now he ask for response details from one of the peers (usually the first one to response prior)  more detailed message
        /// </summary>
        /// <param name="request">the request from the peer</param>
        void ISynchronizedState.SynchronizationDetailsRequest(SynchronizationDetailsRequestContainer request)
        {
            if (request.IsOwnMessage)
            {
                return;
            }

            Task <BusinessLogicMessageBase> .Factory.StartNew(() =>
                                                              businessLogic.ProvideSynchronizationDetailResponse(request.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.ProvideSynchronizationDetailResponse() 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 back to the mesh
                Proxy.SynchronizationDetailsResponse(response);
            });
        }
 /// <summary>
 /// The response the peer that received prior the SynchronizationDetailsRequest
 /// </summary>
 /// <param name="response">the request from the peer</param>
 void ISynchronizedState.SynchronizationDetailsResponse(SynchronizationDetailsResponseContainer response)
 {
     Contract.Requires <ArgumentNullException>(response != null);
 }