Exemple #1
0
 public static CdpSession EvalMsg(JObject expression)
 {
     return(CdpSession.Create(Methods.RuntimeEval, new JObject
     {
         ["expression"] = JObject.FromObject(expression),
         ["awaitPromise"] = true,
         ["returnByValue"] = true
     }));
 }
Exemple #2
0
 public static CdpSession EvalMsg(string script)
 {
     return(CdpSession.Create(Methods.RuntimeEval, new JObject
     {
         ["expression"] = script,
         ["awaitPromise"] = true,
         ["returnByValue"] = true
     }));
 }
Exemple #3
0
        public CdpRequest(string method, int id, CdpSession request)
        {
            _method = method;
            _id     = id;
            _data   = JObject.FromObject(new { id = _id, method = _method });
            var pjs = JObject.FromObject(new { sessionId = request.Session });

            pjs["message"]  = request.AsSerialized();
            _data["params"] = pjs;
        }
Exemple #4
0
 private async Task Publish(CdpSession request, CancellationToken token,
                            Action <CdpSession, CdpResponse> callback = null)
 {
     Interlocked.Add(ref _methodId, 1);
     request.Setup(_methodId, _cdpSessionId);
     _cbMap[_methodId] = new SessionCallback
     {
         Id       = _methodId,
         Request  = request,
         Callback = callback ?? HandleCallback
     };
     await Send(new CdpRequest(CdpApi.Methods.TargetSendMsg, _methodId, request));
 }
Exemple #5
0
 internal static CdpSession EvalMsg(dynamic expression)
 {
     return(CdpSession.Create(Methods.RuntimeEval,
                              new { expression, awaitPromise = true, returnByValue = true }));
 }
Exemple #6
0
 internal static CdpSession SetWindowBounds(int windowId, int width, int height, int left = 100, int top = 100,
                                            string windowState = "normal")
 {
     return(CdpSession.Create(Methods.BrowserSetWinBounds,
                              new { windowId, bounds = new { left, top, width, height, windowState } }));
 }
Exemple #7
0
 internal static CdpSession AddScript(string source)
 {
     return(CdpSession.Create(Methods.PageAddScript, new { source }));
 }
Exemple #8
0
 internal static CdpSession AddBinding(string name)
 {
     return(CdpSession.Create(Methods.RuntimeAddBind, new { name }));
 }
Exemple #9
0
 internal static CdpSession Navigate(string url)
 {
     return(CdpSession.Create(Methods.PageNavigate, new { url }));
 }
Exemple #10
0
 private void HandleCallback(CdpSession request, CdpResponse response)
 {
 }
Exemple #11
0
 private void Publish(CdpSession message, Action <CdpSession, CdpResponse> callback = null)
 {
     Publish(message, CancellationToken.None, callback).Wait();
 }
Exemple #12
0
 private void Publish(string method, string paramsObj, Action <CdpSession, CdpResponse> callback = null)
 {
     Publish(CdpSession.Create(method, paramsObj), CancellationToken.None, callback).Wait();
 }
Exemple #13
0
 public async Task Execute(CdpSession message, CancellationToken token)
 {
     await Publish(message, CancellationToken.None);
 }