public bool Execute(string name, ICefV8Value obj, ICefV8Value[] arguments, out ICefV8Value returnValue, out string exception) { returnValue = null; exception = null; long frameId = 0; using (var context = CefV8Context.GetCurrentContext()) { frameId = context.GetFrame().Identifier; } var executionId = functionCallRegistry.Save(frameId, out var promise); returnValue = promise.Object; var message = new RpcResponse <ICefValue> { MethodExecution = new MethodExecution <ICefValue> { ExecutionId = executionId, MethodId = descriptor.Id, ObjectId = objectId, Parameters = arguments.Select(a => v8Serializer.Serialize(a)).ToArray() } }; using (var context = CefV8Context.GetCurrentContext()) { var msg = CefProcessMessage.Create(Messages.RpcResponseMessage); var serialized = v8Serializer.Serialize(message); msg.Arguments.SetValue(0, serialized.Copy()); context.GetBrowser().SendProcessMessage(CefProcessId.Browser, msg); } return(true); }
public CefV8Value OnBindingRequire(CefV8Value cefV8Value) { using (var context = CefV8Context.GetCurrentContext()) using (var frame = context.GetFrame()) { var frameId = frame.Identifier; var frameObjectCache = objectCache[frameId]; var id = dynamicObjectPromiseRegistry.Save(frameId, out var promise); var objectName = cefV8Value.GetStringValue(); if (!frameObjectCache.TryGetValue(objectName, out var cached)) { if (objectDescriptorCache.TryGetValue(objectName, out var descriptor)) { CreateV8Value(descriptor, dynamicObjectPromiseRegistry.Get(id)); } else { var response = new RpcResponse <CefValue> { DynamicObjectRequest = new DynamicObjectRequest { ExecutionId = id, Name = objectName } }; SendResponse(response); } } else { dynamicObjectPromiseRegistry.Get(id).Resolve(cached); } return(promise.Object); } }