internal override void OnMessage(string method, JsonElement?serverParams)
        {
            switch (method)
            {
            case "close":
                Close?.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 "page":
                Page?.Invoke(
                    this,
                    new() { PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.DefaultJsonSerializerOptions) });
                break;

            case "crBackgroundPage":
                BackgroundPage?.Invoke(
                    this,
                    new() { PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.DefaultJsonSerializerOptions) });
                break;

            case "crServiceWorker":
                ServiceWorker?.Invoke(
                    this,
                    new() { WorkerChannel = serverParams?.GetProperty("worker").ToObject <WorkerChannel>(Connection.DefaultJsonSerializerOptions) });
                break;

            case "request":
                Request?.Invoke(this, serverParams?.ToObject <BrowserContextChannelRequestEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;

            case "requestFinished":
                RequestFinished?.Invoke(this, serverParams?.ToObject <BrowserContextChannelRequestEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;

            case "requestFailed":
                RequestFailed?.Invoke(this, serverParams?.ToObject <BrowserContextChannelRequestEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;

            case "response":
                Response?.Invoke(this, serverParams?.ToObject <BrowserContextChannelResponseEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;
            }
        }
        internal override void OnMessage(string method, JsonElement?serverParams)
        {
            switch (method)
            {
            case "close":
                Close?.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 "page":
                Page?.Invoke(
                    this,
                    new BrowserContextPageEventArgs
                {
                    PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.GetDefaultJsonSerializerOptions()),
                });
                break;

            case "crBackgroundPage":
                BackgroundPage?.Invoke(
                    this,
                    new BrowserContextPageEventArgs
                {
                    PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.GetDefaultJsonSerializerOptions()),
                });
                break;

            case "crServiceWorker":
                ServiceWorker?.Invoke(
                    this,
                    new WorkerChannelEventArgs
                {
                    WorkerChannel = serverParams?.GetProperty("worker").ToObject <WorkerChannel>(Connection.GetDefaultJsonSerializerOptions()),
                });
                break;
            }
        }
        internal ChromiumBrowserContext(IChannelOwner parent, string guid, BrowserContextInitializer initializer) : base(parent, guid, initializer)
        {
            if (initializer.CrBackgroundPages != null)
            {
                foreach (var pageChannel in initializer.CrBackgroundPages)
                {
                    var page = ((PageChannel)pageChannel).Object;
                    _crBackgroundPages.Add(page);
                    page.BrowserContext = this;
                    BackgroundPage?.Invoke(this, new PageEventArgs {
                        Page = page
                    });
                }
            }

            Channel.BackgroundPage += (sender, e) =>
            {
                var page = e.PageChannel.Object;
                page.BrowserContext = this;
                _crBackgroundPages.Add(page);
                BackgroundPage?.Invoke(this, new PageEventArgs {
                    Page = page
                });
            };

            if (initializer.CrServiceWorkers != null)
            {
                foreach (var workerChannel in initializer.CrServiceWorkers)
                {
                    var worker = ((WorkerChannel)workerChannel).Object;
                    ServiceWorkersList.Add(worker);
                    worker.BrowserContext = this;
                    ServiceWorker?.Invoke(this, new WorkerEventArgs(worker));
                }
            }

            Channel.ServiceWorker += (sender, e) =>
            {
                var worker = e.WorkerChannel.Object;
                ServiceWorkersList.Add(worker);
                worker.BrowserContext = this;
                ServiceWorker?.Invoke(this, new WorkerEventArgs(worker));
            };
        }