Class PageConn


  • public class PageConn
    extends java.lang.Object
    A Connection to a specific page within a browser.

    Field Extraction Behavior for PageConn, from a JsonObject

    Field isOptional throwOnNull
    id ❌ false ✅ true
    type ❌ false ✅ true
    title ✅ true ❌ false
    url ❌ false ✅ true
    description ✅ true ❌ false
    webSocketDebuggerUrl ❌ false ✅ true
    devtoolsFrontendUrl ✅ true ❌ false
    faviconUrl ✅ true ❌ false

    🔥 Why This Works

    Feature Explanation
    Predictable: You will never silently receive null on a required field.
    Traceable: If Chrome breaks compatibility, you'll get an exception pointing directly to it.
    Safe: Chrome Optional fields that disappear or return null won't break anything.

    This is exactly how you should structure a wrapper for an external spec you don't control — aggressive for connection-critical data, forgiving for decorative or diagnostic fields.

    💡 If Google changes their output?

    You'll know immediately — and you'll see exactly which field failed in a JsonPropMissingException or JsonNullObjException thanks to your excellent ReadJSON layer.


    Page originally drafted by ChatGPT on 2025-07-16.
    Edited and formatted for use in the Browser RDP Tool's documentation.



    • Constructor Summary

      Constructors 
      Constructor Description
      PageConn​(String id, String type, String title, String url, String description, String webSocketDebuggerUrl, String devtoolsFrontendUrl, String faviconUrl)  
      PageConn​(JsonObject jo)  
    • Method Summary

       
      Create Page / Tab WebSocket Sender
      Modifier and Type Method Description
      WebSocketSender createSender​(Consumer<BrowserEvent> eventHandler, Consumer<RDPError> rdpErrorHandler, Consumer<BrowserError> browserErrorHandler)
      Creates a WebSocketSender connected to the webSocketDebuggerUrl for this tab.
       
      Static-Getter: Creates a Stream of Instance of this Class
      Modifier and Type Method Description
      static Stream<PageConn> getAllPageConn​(Integer port, boolean quiet)
      Retrieves all pages from the CDP-RDP endpoint currently open on the named port.
       
      Methods: class java.lang.Object
      Modifier and Type Method Description
      boolean equals​(Object o)  
      int hashCode()  
      String toString()  
       
      Methods: interface java.lang.Cloneable
      Modifier and Type Method Description
      PageConn clone()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • id

        🡇     🗕  🗗  🗖
        public final java.lang.String id
        Unique identifier for the DevTools target (usually a browser tab or iframe).
        Code:
        Exact Field Declaration Expression:
         public final String id;
        
      • type

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String type
        The type of target, typically "page", but can also be "iframe", etc.
        Code:
        Exact Field Declaration Expression:
         public final String type;
        
      • title

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String title
        The title of the web page as reported by the browser.
        Code:
        Exact Field Declaration Expression:
         public final String title;
        
      • url

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String url
        The URL currently loaded in the target/tab.
        Code:
        Exact Field Declaration Expression:
         public final String url;
        
      • description

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String description
        Optional description of the DevTools target. Often an empty string.
        Code:
        Exact Field Declaration Expression:
         public final String description;
        
      • webSocketDebuggerUrl

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String webSocketDebuggerUrl
        WebSocket endpoint to connect to this target via the Chrome DevTools Protocol.
        Code:
        Exact Field Declaration Expression:
         public final String webSocketDebuggerUrl;
        
      • devtoolsFrontendUrl

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String devtoolsFrontendUrl
        Internal URL that opens Chrome's DevTools frontend UI for this target.
        Code:
        Exact Field Declaration Expression:
         public final String devtoolsFrontendUrl;
        
      • faviconUrl

        🡅  🡇     🗕  🗗  🗖
        public final java.lang.String faviconUrl
        The URL of the favicon for the target page, if available.
        Code:
        Exact Field Declaration Expression:
         public final String faviconUrl;
        
    • Constructor Detail

      • PageConn

        🡅  🡇     🗕  🗗  🗖
        public PageConn​(java.lang.String id,
                        java.lang.String type,
                        java.lang.String title,
                        java.lang.String url,
                        java.lang.String description,
                        java.lang.String webSocketDebuggerUrl,
                        java.lang.String devtoolsFrontendUrl,
                        java.lang.String faviconUrl)
    • Method Detail

      • createSender

        🡅  🡇     🗕  🗗  🗖
        public WebSocketSender createSender​
                    (java.util.function.Consumer<BrowserEvent> eventHandler,
                     java.util.function.Consumer<RDPError> rdpErrorHandler,
                     java.util.function.Consumer<BrowserError> browserErrorHandler)
                throws java.io.IOException,
                       WebSocketException
        
        Creates a WebSocketSender connected to the webSocketDebuggerUrl for this tab. This URL is the endpoint that speaks the Chrome DevTools Protocol (CDP).
        Parameters:
        eventHandler - Provide any Java-Consumer>BrowserEvent>. Null may not be passed to this parameter, or NullPointerException throws.
        rdpErrorHandler - Accepts any Java-Consumer<RDPError>. If null is passed to this parameter, then a default {@code 'No Op'} handler will be used for constructing the WebSocketSender instance.

        Error Type: This Error-Handler will accept notices about errors which may or may not have occured with the underlying transport mechanism. The types of errors which would, conceivably, be sent to this handler are exactly the type of errors which shouldn't ever occurr. In essence, this parameter is an "assertion failure" notice receiver to which Web-Socket Errors are transmitted. Web-Socket Connection Failures should be Unreachable, but since I/O Problems can always be an issue, this Handler is provided even though its messages should not be possible in a properly debugged environment.
        browserErrorHandler - Accepts any Java-Consumer<BrowserError>. If null is passed to this parameter, then a default 'No Op' handler will be used for constructing the WebSocketSender instance.

        Error Type: This Error-Handler will accept notices about errors which have been broadcast by the Web-Browser, across the Web-Sockets Connection, back to this API. These are Browser-Layer Errors, received by Web-Socket Message Frames. These type of Errors are not Transport-Layer, Web-Socket Errors.
        Throws:
        java.io.IOException
        WebSocketException
        Code:
        Exact Method Body:
         return new WebSocketSender
             (this.webSocketDebuggerUrl, eventHandler, rdpErrorHandler, browserErrorHandler);
        
      • getAllPageConn

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public static java.util.stream.Stream<PageConngetAllPageConn​
                    (java.lang.Integer port,
                     boolean quiet)
        
        Retrieves all pages from the CDP-RDP endpoint currently open on the named port. This queries /json/list and returns a Java-Stream of the instnces of this class.
        Parameters:
        port - The DevTools port Chrome is listening on (default is 9222 if null).
        quiet - If TRUE, output is shunted.
        Returns:
        A list of all Open-Pages, as instances of PageConn
        Code:
        Exact Method Body:
         return PCBuilder.getAllPageConn(port, quiet);
        
      • toString

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Code:
        Exact Method Body:
         return PCHelper.toString(this);
        
      • hashCode

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Code:
        Exact Method Body:
         return PCHelper.hashCode(this);
        
      • equals

        🡅  🡇         External-Java:    🗕  🗗  🗖
        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
        Code:
        Exact Method Body:
         return PCHelper.equals(this, o);
        
      • clone

        🡅         External-Java:    🗕  🗗  🗖
        public PageConn clone()
        Overrides:
        clone in class java.lang.Object
        Code:
        Exact Method Body:
         return PCHelper.clone(this);