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