// Copyright © 2020 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System; using System.Collections.Generic; using System.Threading.Tasks; namespace CefSharp.DevTools { /// /// DevTools Client /// public interface IDevToolsClient : IDisposable { /// /// Will be called on receipt of a DevTools protocol event. Events by default are disabled and need to be /// enabled on a per domain basis, e.g. Sending Network.enable (or calling ) /// to enable network related events. /// event EventHandler DevToolsEvent; /// /// Will be called when an error occurs when attempting to raise /// event EventHandler DevToolsEventError; /// /// Add event handler for a DevTools protocol event. Events by default are disabled and need to be /// enabled on a per domain basis, e.g. Sending Network.enable (or calling ) /// to enable network related events. /// /// The event args type to which the event will be deserialized to. /// is the event name to listen to /// event handler to call when the event occurs void AddEventHandler(string eventName, EventHandler eventHandler) where T : EventArgs; /// /// Remove event handler for a DevTools protocol event. /// /// The event args type to which the event will be deserialized to. /// is the event name to listen to /// event handler to call when the event occurs /// /// Returns false if all handlers for the have been removed, /// otherwise returns true if there are still handlers registered. /// bool RemoveEventHandler(string eventName, EventHandler eventHandler) where T : EventArgs; /// /// Execute a method call over the DevTools protocol. This method can be called on any thread. /// See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details /// of supported methods and the expected dictionary contents. /// /// The type to which the method result will be deserialzed to. /// is the method name /// are the method parameters represented as a dictionary, /// which may be empty. /// return a Task that can be awaited to obtain the method result Task ExecuteDevToolsMethodAsync(string method, IDictionary parameters = null) where T : DevToolsDomainResponseBase; } }