Connection
Namespace: PuppeteerSharp.Cdp
public sealed class Connection : IDisposable, ICDPConnectionA connection handles the communication with a Chromium browser.
Inheritance: object
Implements: IDisposable, ICDPConnection
Properties
Section titled “Properties”CloseReason
Section titled “CloseReason”public string CloseReason { get; }Connection close reason.
Value: string
public int Delay { get; }Gets the sleep time when a message is received.
Value: int — The delay.
IsClosed
Section titled “IsClosed”public bool IsClosed { get; }Gets a value indicating whether this Connection is closed.
Value: bool — true if is closed; otherwise, false.
LoggerFactory
Section titled “LoggerFactory”public ILoggerFactory LoggerFactory { get; }Gets the logger factory.
Value: ILoggerFactory — The logger factory.
Transport
Section titled “Transport”public IConnectionTransport Transport { get; }Gets the Connection transport.
Value: IConnectionTransport — Connection transport.
public string Url { get; }Gets the WebSocket URL.
Value: string — The URL.
Events
Section titled “Events”Disconnected
Section titled “Disconnected”public event EventHandler DisconnectedOccurs when the connection is closed.
Value: EventHandler
MessageReceived
Section titled “MessageReceived”public event EventHandler<MessageEventArgs> MessageReceivedOccurs when a message from chromium is received.
Value: EventHandler<MessageEventArgs>
Methods
Section titled “Methods”Dispose()
Section titled “Dispose()”public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
SendAsync(string, object, bool, CommandOptions)
Section titled “SendAsync(string, object, bool, CommandOptions)”public Task<JsonElement?> SendAsync(string method, object args = null, bool waitForCallback = true, CommandOptions options = null)Protocol methods can be called with this method.
Parameters
| Name | Type | Description |
|---|---|---|
method |
string | The method name. |
args |
object | The method args. |
waitForCallback |
bool | If true the method will return a task to be completed when the message is confirmed by Chromium. If false the task will be considered complete after sending the message to Chromium. |
options |
CommandOptions | The options. |
Returns: Task<JsonElement?> — The task.
Exceptions
| Type | Condition |
|---|---|
| PuppeteerException | If the Connection is closed. |
SendAsync<T>(string, object, CommandOptions)
Section titled “SendAsync<T>(string, object, CommandOptions)”public Task<T> SendAsync<T>(string method, object args = null, CommandOptions options = null)Protocol methods can be called with this method.
Type parameters
| Name | Description |
|---|---|
T |
Return type. |
Parameters
| Name | Type | Description |
|---|---|---|
method |
string | The method name. |
args |
object | The method args. |
options |
CommandOptions | The options. |
Returns: Task<T> — The task.
Made with love by Dario Kondratiuk