mafredri / cdp

Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language.
MIT License
724 stars 45 forks source link

FR: Improvements to session manager #103

Open DrMarcII opened 5 years ago

DrMarcII commented 5 years ago

I am trying to use the session manager in a context where I want to attach to all existing targets, and then attach to and get messages about detaching from all targets as they are created/destroyed. I have something mostly working, but it is more complex and fragile than I would prefer:

  1. Support enabling https://chromedevtools.github.io/devtools-protocol/tot/Target#method-setAutoAttach. Since there is no way to get rpcc.Conn or cdp.Client for an already attached session, it is difficult to interact with an auto attached session.

  2. Provide access to the current sessionID for an rpcc.Conn or cdp.Client. targetId is deprecated in https://chromedevtools.github.io/devtools-protocol/tot/Target#event-detachedFromTarget, but there is currently no ready way to identify the sessionId for an rpcc.Conn or cdp.Client (it currently can be done by creating a map of sessionId to targetId when attachedToTarget events are fired, except in for the initial client).

mafredri commented 5 years ago

Thanks for raising this issue, I'll need to give it some thought as to how this could be accomplished but it's a good feature request. In the first design of sessions I played around with auto attaching but ended up omitting it to keep it simpler.