RemoteDesktop
The following example demonstrates how to request a browser instance, connect to it via Puppeteer, start a remote desktop session, and then stop the remote desktop session.
Full example
This code initializes a browser session, starts a remote desktop session for that browser, and then stops the remote desktop after a short delay. Here’s a breakdown:
1. Browser Session Initialization
A
BrowserService
instance is created usingcloudBrowserToken
for authentication.The
svc.open()
method is called to request a browser session. If the request fails or the WebSocket endpoint (rp.address
) is not provided, an error message is logged, and the script terminates.If successful, it logs that the browser has been requested.
2. Starting a Remote Desktop Session
The
svc.startRemoteDesktop(rp.address)
method is used to enable a remote desktop interface for the browser session. Thermt.password
is generated for secure access.The script constructs and logs a URL to access the remote desktop session using the browser's ID (
obtainId(rp.address)
) and password.
3. Delay and Stop Remote Desktop
The script pauses for 5 seconds using
setTimeout
, allowing interaction with the remote desktop session during this time.After the delay, the
svc.stopRemoteDesktop(rp.address)
method is called to terminate the remote desktop session.
Last updated