Skip to content

Connection

Namespace: PuppeteerSharp.Cdp

public sealed class Connection : IDisposable, ICDPConnection

A connection handles the communication with a Chromium browser.

Inheritance: object

Implements: IDisposable, ICDPConnection

View source

public string CloseReason { get; }

Connection close reason.

Value: string

View source

public int Delay { get; }

Gets the sleep time when a message is received.

Value: int — The delay.

View source

public bool IsClosed { get; }

Gets a value indicating whether this Connection is closed.

Value: bool — true if is closed; otherwise, false.

View source

public ILoggerFactory LoggerFactory { get; }

Gets the logger factory.

Value: ILoggerFactory — The logger factory.

View source

public IConnectionTransport Transport { get; }

Gets the Connection transport.

Value: IConnectionTransport — Connection transport.

View source

public string Url { get; }

Gets the WebSocket URL.

Value: string — The URL.

View source

public event EventHandler Disconnected

Occurs when the connection is closed.

Value: EventHandler

View source

public event EventHandler<MessageEventArgs> MessageReceived

Occurs when a message from chromium is received.

Value: EventHandler<MessageEventArgs>

View source

public void Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View source

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.

View source

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.

View source

Made with love by Dario Kondratiuk