internal override void OnMessage(string method, JsonElement?serverParams) { switch (method) { case "close": Closed?.Invoke(this, EventArgs.Empty); break; case "crash": Crashed?.Invoke(this, EventArgs.Empty); break; case "domcontentloaded": DOMContentLoaded?.Invoke(this, EventArgs.Empty); break; case "load": Load?.Invoke(this, EventArgs.Empty); break; case "bindingCall": BindingCall?.Invoke( this, new() { BindingCall = serverParams?.GetProperty("binding").ToObject <BindingCallChannel>(Connection.DefaultJsonSerializerOptions).Object }); break; case "route": var route = serverParams?.GetProperty("route").ToObject <RouteChannel>(Connection.DefaultJsonSerializerOptions).Object; var request = serverParams?.GetProperty("request").ToObject <RequestChannel>(Connection.DefaultJsonSerializerOptions).Object; Route?.Invoke( this, new() { Route = route, Request = request }); break; case "popup": Popup?.Invoke(this, new() { Page = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.DefaultJsonSerializerOptions).Object }); break; case "pageError": PageError?.Invoke(this, serverParams?.GetProperty("error").GetProperty("error").ToObject <SerializedError>(Connection.DefaultJsonSerializerOptions)); break; case "fileChooser": FileChooser?.Invoke(this, serverParams?.ToObject <FileChooserChannelEventArgs>(Connection.DefaultJsonSerializerOptions)); break; case "frameAttached": FrameAttached?.Invoke(this, serverParams?.GetProperty("frame").ToObject <FrameChannel>(Connection.DefaultJsonSerializerOptions).Object); break; case "frameDetached": FrameDetached?.Invoke(this, serverParams?.GetProperty("frame").ToObject <FrameChannel>(Connection.DefaultJsonSerializerOptions).Object); break; case "dialog": Dialog?.Invoke(this, serverParams?.GetProperty("dialog").ToObject <DialogChannel>(Connection.DefaultJsonSerializerOptions).Object); break; case "console": Console?.Invoke(this, serverParams?.GetProperty("message").ToObject <ConsoleMessage>(Connection.DefaultJsonSerializerOptions)); break; case "webSocket": WebSocket?.Invoke(this, serverParams?.GetProperty("webSocket").ToObject <WebSocketChannel>(Connection.DefaultJsonSerializerOptions).Object); break; case "download": Download?.Invoke(this, serverParams?.ToObject <PageDownloadEvent>(Connection.DefaultJsonSerializerOptions)); break; case "video": Video?.Invoke(this, new() { Artifact = serverParams?.GetProperty("artifact").ToObject <ArtifactChannel>(Connection.DefaultJsonSerializerOptions).Object }); break; case "worker": Worker?.Invoke( this, new() { WorkerChannel = serverParams?.GetProperty("worker").ToObject <WorkerChannel>(Connection.DefaultJsonSerializerOptions) }); break; } }
internal override void OnMessage(string method, JsonElement?serverParams) { switch (method) { case "close": Closed?.Invoke(this, EventArgs.Empty); break; case "crash": Crashed?.Invoke(this, EventArgs.Empty); break; case "domcontentloaded": DOMContentLoaded?.Invoke(this, EventArgs.Empty); break; case "load": Load?.Invoke(this, EventArgs.Empty); break; case "bindingCall": BindingCall?.Invoke( this, new BindingCallEventArgs { BidingCall = serverParams?.GetProperty("binding").ToObject <BindingCallChannel>(Connection.GetDefaultJsonSerializerOptions()).Object, }); break; case "route": Route?.Invoke( this, new RouteEventArgs { Route = serverParams?.GetProperty("route").ToObject <RouteChannel>(Connection.GetDefaultJsonSerializerOptions()).Object, Request = serverParams?.GetProperty("request").ToObject <RequestChannel>(Connection.GetDefaultJsonSerializerOptions()).Object, }); break; case "popup": Popup?.Invoke(this, new PageChannelPopupEventArgs { Page = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.GetDefaultJsonSerializerOptions()).Object, }); break; case "pageError": PageError?.Invoke(this, serverParams?.GetProperty("error").GetProperty("error").ToObject <PageErrorEventArgs>(Connection.GetDefaultJsonSerializerOptions())); break; case "fileChooser": FileChooser?.Invoke(this, serverParams?.ToObject <FileChooserChannelEventArgs>(Connection.GetDefaultJsonSerializerOptions())); break; case "frameAttached": FrameAttached?.Invoke(this, new FrameEventArgs(serverParams?.GetProperty("frame").ToObject <FrameChannel>(Connection.GetDefaultJsonSerializerOptions()).Object)); break; case "frameDetached": FrameDetached?.Invoke(this, new FrameEventArgs(serverParams?.GetProperty("frame").ToObject <FrameChannel>(Connection.GetDefaultJsonSerializerOptions()).Object)); break; case "dialog": Dialog?.Invoke(this, new DialogEventArgs(serverParams?.GetProperty("dialog").ToObject <DialogChannel>(Connection.GetDefaultJsonSerializerOptions()).Object)); break; case "console": Console?.Invoke(this, new ConsoleEventArgs(serverParams?.GetProperty("message").ToObject <ConsoleMessage>(Connection.GetDefaultJsonSerializerOptions()))); break; case "request": Request?.Invoke(this, new RequestEventArgs { Request = serverParams?.GetProperty("request").ToObject <RequestChannel>(Connection.GetDefaultJsonSerializerOptions()).Object }); break; case "requestFinished": RequestFinished?.Invoke(this, new RequestEventArgs { Request = serverParams?.GetProperty("request").ToObject <RequestChannel>(Connection.GetDefaultJsonSerializerOptions()).Object }); break; case "requestFailed": RequestFailed?.Invoke(this, serverParams?.ToObject <PageChannelRequestFailedEventArgs>(Connection.GetDefaultJsonSerializerOptions())); break; case "response": Response?.Invoke(this, new ResponseEventArgs { Response = serverParams?.GetProperty("response").ToObject <ResponseChannel>(Connection.GetDefaultJsonSerializerOptions()).Object }); break; case "download": Download?.Invoke(this, new DownloadEventArgs() { Download = serverParams?.GetProperty("download").ToObject <DownloadChannel>(Connection.GetDefaultJsonSerializerOptions()).Object }); break; case "worker": Worker?.Invoke( this, new WorkerChannelEventArgs { WorkerChannel = serverParams?.GetProperty("worker").ToObject <WorkerChannel>(Connection.GetDefaultJsonSerializerOptions()), }); break; } }
internal void OnDOMContentLoaded() => DOMContentLoaded?.Invoke(this, new EventArgs());