Package Torello.Browser
Class PageConn
- java.lang.Object
-
- Torello.Browser.PageConn
-
public class PageConn extends java.lang.Object
A Connection to a specific page within a browser.Field Extraction Behavior for
PageConn
, from aJsonObject
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 aJsonPropMissingException
orJsonNullObjException
thanks to your excellentReadJSON
layer.
Page originally drafted by ChatGPT on 2025-07-16.
Edited and formatted for use in the Browser RDP Tool's documentation.
Hi-Lited Source-Code:- View Here: Torello/Browser/PageConn.java
- Open New Browser-Tab: Torello/Browser/PageConn.java
File Size: 7,186 Bytes Line Count: 178 '\n' Characters Found
-
-
Field Summary
Fields Modifier and Type Field Description String
description
String
devtoolsFrontendUrl
String
faviconUrl
String
id
String
title
String
type
String
url
String
webSocketDebuggerUrl
-
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 aWebSocketSender
connected to thewebSocketDebuggerUrl
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()
-
-
-
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)
-
PageConn
public PageConn(JsonObject jo)
-
-
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 aWebSocketSender
connected to thewebSocketDebuggerUrl
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, orNullPointerException
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 theWebSocketSender
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 theWebSocketSender
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
public static java.util.stream.Stream<PageConn> getAllPageConn (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 ifnull
).quiet
- IfTRUE
, output is shunted.- Returns:
- A list of all Open-Pages, as instances of
PageConn
- Code:
- Exact Method Body:
return PCBuilder.getAllPageConn(port, quiet);
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Code:
- Exact Method Body:
return PCHelper.toString(this);
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- Code:
- Exact Method Body:
return PCHelper.hashCode(this);
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
- Code:
- Exact Method Body:
return PCHelper.equals(this, o);
-
clone
-
-