示例#1
0
        private async Task OnInitialPatch(ProtocolJsonPatchPayload payload)
        {
            try
            {
                Log.Information($"Initializing with first patch ({payload.Changes?.Length})");
                await _prepareTask;

                Log.Information("Applying changes");
                // we want to initialize everything in background thread
                _coreData.GetManager().ApplyChanges(_serverClient, payload.Changes);
                ProcessSubscriptions();
                await InitializeAfterFirstPatchAsync();

                ProcessSubscriptions();
                await SendPatch();

                Log.Information("Initialized with first patch");

                _firstPatchReceived = true;
                _firstPatchTcs.TrySetResult(true);

                // process again. Required as process subscriptions can be ignored due to _firstPatchReceived = false
                ProcessSubscriptions();
            }
            catch (Exception e)
            {
                Log.Error(e, "OnInitialPatch failed");
                _firstPatchTcs.TrySetException(e);
            }
        }
示例#2
0
 private async Task OnPatchOnMainThread(ProtocolJsonPatchPayload payload)
 {
     if (SynchronizationContext.Current == null)
     {
         // we are on working thread
         _coreData.RunOnMainThread(() => { _ = OnPatch(payload); });
     }
     else
     {
         await OnPatch(payload);
     }
 }
示例#3
0
 private async Task OnPatch(ProtocolJsonPatchPayload payload)
 {
     Log.Debug($"{{---{payload.Changes}");
     if (_firstPatchReceived)
     {
         _coreData.GetManager().ApplyChanges(_serverClient, payload.Changes);
     }
     else if (payload.Reset)
     {
         await OnInitialPatch(payload);
     }
     else
     {
         Log.Warning("Fake initial patch");
     }
 }