示例#1
0
        private void HandleBindingResult(RpcRequest <CefValue> response)
        {
            var dynamicObjectResult = response.DynamicObjectResult;

            if (dynamicObjectPromiseRegistry.Has(dynamicObjectResult.ExecutionId))
            {
                using (var promise = dynamicObjectPromiseRegistry.Get(dynamicObjectResult.ExecutionId))
                    using (new ContextHelper(promise.Context))
                    {
                        if (dynamicObjectResult.Success)
                        {
                            var objectDescriptor = dynamicObjectResult.ObjectDescriptor;
                            //this can happen when multiple frames are requesting the same object and the previous request was not answered yet
                            if (!objectDescriptorCache.ContainsKey(objectDescriptor.Name))
                            {
                                objectDescriptorCache.Add(objectDescriptor.Name, objectDescriptor);
                            }

                            CreateV8Value(objectDescriptor, promise);
                        }
                        else
                        {
                            promise.Reject(dynamicObjectResult.Exception);
                        }
                    }
            }
        }
示例#2
0
 private void HandleMethodResult(RpcRequest <CefValue> response)
 {
     if (functionCallPromiseRegistry.Has(response.MethodResult.ExecutionId))
     {
         using (var promise = functionCallPromiseRegistry.Get(response.MethodResult.ExecutionId))
             using (new ContextHelper(promise.Context))
             {
                 if (response.MethodResult.Success)
                 {
                     promise.Resolve((CefV8Value)objectSerializer.Deserialize(response.MethodResult.Result, typeof(CefV8Value)));
                 }
                 else
                 {
                     promise.Reject(response.MethodResult.Error);
                 }
             }
     }
 }